Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

How can I enable the unique location and zoom level of a user on a web-map to be shared?

For example, if a user zooms to lat: 75, lon: 35, zoom: 8, I would like to be able for the user to share that location through a link (for example, www.mymap.com/75/35/8). As I'm using OpenLayers, I understand how to record where the lat/lon/zoom of what the user is viewing, and also how to store this in a database if necessary, but I do not have a clear idea how (or if) this argument can be shared via the browser.

My OpenLayers code is usually something of this form:

var mapCenter = new OpenLayers.LonLat(-35, 75);             
map.setCenter(mapCenter, 3);  

For example, I would like www.mymap.com/23/15/10 to work, and all other permutations of lat/lon/zoom.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

Let see this permalink example from OpenLayers site. URL in this case looks like:

http://openlayers.org/dev/examples/controls.html?zoom=3&lat=1.05469&lon=-1.40625&layers=0BF

As you can see alongside coordinates of map center and zoom level you can transfer list of visible layers. For detailed information see source code of Permalink control.

share|improve this answer
add comment

You would do something like www.mymap.com?lat=75&lon=35&zoom=8. Then you can either send this to some server side script, extract the variables from the URL and make map use them, or you can use client side Javascript code (I would go for window.location) and do generally the same.

share|improve this answer
add comment

Your Answer

 
discard

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.