0

Is it possible to use static maps API using named maps placeholders?

I've a private dataset and I need to enhance some features at the output.

In more details, I've a layer of land uses and I need to create a PDF of an specific plot of my layer. I'd like to get an image of the layer with the selected plot enhanced over the others.

If it's not supported I'll try the hack using phantomjs + cartodbjs

2

1 Answer 1

1

You can find the basics of retrieving named map images at: Create a named map with a base map - without Javascript or browser. Basically, you need to instantiate your named map to obtain the layergroup ID and then perform requests to the Static Maps API as it if was an anonymous map.

In your case, if your named map has placeholders (parameters), then you would need to include the values for them in the instantiation which is required to obtain the layergroup id.

From the docs here, your instantiation request would be something similar to:

curl -X POST \
  -H 'Content-Type: application/json' \
  -d @params.json \
  'https://{username}.cartodb.com/api/v1/map/named/{template_name}'

being @params.json a JSON file with the values for your placeholders, for example:

{
 "color": "#ff0000",
 "cartodb_id": 3
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.