1

I noticed recently that my published iframe map adjusts to whatever the zoom and centering is for that map on the cartodb site. So if I'm playing around with the cartodb map on cartodb, say exploring particular regions of the map, this will have a direct impact on what my website users see in the embedded map.

Is there a way to avoid this? I don't see any parameters for setting center or zoom in the iframe code:

<iframe width='100%' height='520' frameborder='0' src='http://sanjuro.cartodb.com/viz/10f021cc-b7a5-11e4-a4dd-0e853d047bba/embed_map' allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen></iframe>
0

You can specify some flags in the URL to get the view you want.

The example below centers on [lat,long] = [34,-122] with zoom equal to 5.

http://team.cartodb.com/u/santiagoa/viz/4a39c7f8-b6ce-11e4-9da5-0e853d047bba/embed_map?center=[34,-122]&zoom=5

0

Just to complete a little bit Andy's answer with the information in the CartoDB Documentation here: http://docs.cartodb.com/faqs.html

In order to set the initial position of a map that you want to embed, you just need to adjust this position and the zoom value in the map of the visualization. If you want to edit the way that your links and embed maps are centered/zoomed after sharing, you can add the zoom, latitude and longitude parameters to the simple URL as follows:

http://<username>.cartodb.com/viz/<viz_id>/embed_map?zoom=3&center_lat=0&center_lon=0

You can also use the same trick in the HTML code that is given to embed your maps.

In case you’re using CartoDB.js, you can include these values in the options of the createVis method:

cartodb.createVis('map', 'http://documentation.cartodb.com/api/v2/viz/2b13c956-e7c1-11e2-806b-5404a6a683d5/viz.json', {
  center_lat: 43.90,
  center_lon: -97.55,
  zoom: 5
});
  • Thanks for the addition. Not enough reputation yet to upvote, sorry. – Sanjuro Feb 23 '15 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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