mlevans / leaflet-hash

Add URL hashes to web pages with Leaflet maps.
http://mlevans.github.io/leaflet-hash/
MIT License
303 stars 89 forks source link

Endless redirects #12

Open stevevance opened 11 years ago

stevevance commented 11 years ago

I referenced leaflet-hash.js and added var hash = new L.Hash(map); after initializing the map. Upon the first loading of the page, the page loads the UI, loads the map, and then goes blank as the browser gets in an endless loop.

I think this may have something to do with jQueryMobile (I get a jQueryMobile-provided "error loading" on-screen message). Let me know if you need me to go into more details or provide a screencast of the loop.

stevevance commented 11 years ago

Update: jQueryMobile is messing this up because it is listening to hash changes and trying to do something about the changing hash. It can be disabled with

$(document).bind("mobileinit", function(){
    $.mobile.hashListeningEnabled = false;
});

But, a problem isn't gone completely.

Here's what happens:

  1. The map loads: http://localhost/map.html
  2. The URL immediately changes to http://localhost/14/41.8821/-87.6278
  3. I move the map and then the page reloads and the URL is now http://localhost/map.html#14/41.8883/-87.6488
  4. I move the map again and the URL changes to http://localhost/14/41.8968/-87.6736
  5. I move the map a third time and the page reloads and the URL is now http://localhost/map.html#14/41.9086/-87.6832

I was able to use the Permalink plugin which I believe provides an identical function. It worked properly in my webpage.