Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


Is there a way to set the xy and zoom level of a map using the URL of the site that is calling it?

I'm thinking of a site I'm using now, built on php, which has mapbox maps built in javascript and added to a DIV.

Could there be a way to use something like:

http: //

Does that make sense?


share|improve this question
up vote 2 down vote accepted

If you're using mapbox.js directly, you can call map.ui.hash.add() (assuming your map variable is named map), and the page will have a hash like #10.00/45.5342/-73.7457 which encodes the zoom level, latitude, and longitude of the map position, and you can send users to URLs like that to set the initial map position.

share|improve this answer
Tom - got this to work, and saw the example under 'toggle map controls'. Thank you again!!! – DPSSpatial Dec 12 '12 at 19:57

Here's a code snippet I found online that parses PHP URL variables into JavaScript. You may have to modify it a little to fit your needs, but it's pretty short and simple:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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