3 ms·
This is pretty cool. I'd advise not changing the URL with every map movement and instead let the user generate a linkable URL upon demand. This created quite th
by meritt 11y ago
This is pretty cool. I'd advise not changing the URL with every map movement and instead let the user generate a linkable URL upon demand. This created quite the enormous history list after only using a few minutes.
- xando 11y agoTo be honest this didn't cross my mind. But true, I should do something about it.
- bhousel 11y agoYou can keep your urls sharable and avoid breaking the back button by storing the map state in the url hash. something like: `location.hash = '#map/' + mapLat + '/' + mapLng + '/'+ mapZoom;` Here's an example of one I made for a client recently. http://www.btforasthma.com/find-a-clinic?ctry=US&state=NY&loc=10001#map/40.78079/-73.97894/40.72332/-73.94897/10 http://www.btforasthma.com/find-a-clinic?ctry=US&state=NY&lo... Incidentally, if anyone is looking to hire a consultant with mapping experience, hit me up.
- evan_ 11y agoThat still creates a history state, so if you make 10 map moves, you have to click "back" 11 times to get back to the previous page. replaceState() works a lot better: https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history#The_replaceState()_method https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/M...
- davidbarker 11y agoWould replaceState() help? http://stackoverflow.com/a/20937387/1619998 http://stackoverflow.com/a/20937387/1619998