Simple Extent Sharing for your Map App
A common request for web map applications is to have some sort of bookmark function. Bookmarks are just a quick way of jumping to a saved extent or view for your map and they are usually presented as a list of meaningful names. This is fine when you are using an application but what if you just want a way of sharing an extent with someone or creating a permalink of your extent / view. Here’s a very quick and easy way to do it for the Esri JS API using the window.location.hash
.
We only need to do 2 things for this. First, since we want to know the extent we need to hook into the map extent-change
event and update the location.hash
. Second, when we start the app we need to check the location.hash
and if an extent is there then set the map extent accordingly. That’s it!
Here’s the entire code for the functionality and a live demo. The source for the demo is on GitHub
|
|
Now to enable this you need
|
|