I'm using cartodb's static maps API to create a hi-def printable map. The map is placed on top of a basemap generated in Mapbox studio.

Looks pretty good but I have an issue that prevents me to industrialize the process : When using the anonymous endpoint with a bounding box (http://docs.cartodb.com/cartodb-platform/maps-api.html#bounding-box), the map does not exactly respect the coordinates sent, it's more of an approximation. My intuition is that the renderer needs to stick to a discrete zoom level, and will send a map at this zoom level, with the bounding box center as the center.

So for now, I have to guess what's the bounding box actually set on the cdb map and try and make the Mapbox map use the same bounding box. Not so handy.

A solution could be to use a named map using the view set in the template (http://docs.cartodb.com/cartodb-platform/maps-api.html#named-map), but I really like being able to modify the SQL and the css on the fly.

1 Answer 1


Your intuition was good. We followed up the same issue with CartoDB support, and were given this answer.

Static images use the maximum zoom level on which the given bounding box will fit the static map image in its entirety.

Zoom levels are discrete. It is not possible to get a zoom level that is for example, between 4 and 5.

Also, the images generated are not scaled, so they always take the native resolution from the tile.

So most of the time, the bounding box specified in the request will not be honoured precisely.

Here is the problem as we experienced it. When we specified the thick black bounding box and an image size of 640 by 480 pixels, we expected to get the thin black rectangle, but got the purple one. Similarly with the white.

zoom level illustration

Your Answer

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

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