leaflet-fullHash icon indicating copy to clipboard operation
leaflet-fullHash copied to clipboard

Ready for Leaflet 1?

Open kelv-cz opened this issue 8 years ago • 6 comments
trafficstars

In Leaflet 1 probably do not works :(. URLs with hash tags exist, but link heads to default zoom.

kelv-cz avatar May 03 '17 17:05 kelv-cz

Has anyone looked into this, or an alternate solution?

As far as I could see, the update method is not called until after onMapMove, which overwrites the hash before it is being parsed for the first time. However, If I add some checks around this, it still only removes unselected layers from the default, but does not add the ones from my hash.

relet avatar Sep 14 '17 11:09 relet

That is, I managed to get the positioning and layer selection working with the following code.

https://gist.github.com/relet/6b73fccc6cb2636f1e60c6a5ddc6bf1b

What is missing still seems to be some sort of refresh on the map object. In my tests, when I load the map from a URL with hash:

  • the background layer is correctly set, and the map moved to the correct position.
  • background and overlays are correctly ticked off in the layer selector
  • overlays are not displayed until a refresh, e.g. if the map window is resized

relet avatar Sep 14 '17 12:09 relet

What is confusing me is that the entire vector (geojson) overlay system seems to be disabled until I resize the viewport (either by resizing the window, or opening the debug console). None of the geojson layers appear when I pan or zoom, not even when I select other layers in the layer selector.

relet avatar Sep 15 '17 09:09 relet

Any update on this one? I need it badly.

VoyteckPL avatar Dec 03 '17 08:12 VoyteckPL

Works fine for me on Leaflet 1.3.3

jahands avatar Aug 16 '18 23:08 jahands

I can confirm, with the latest stable version of leaflet, the viewport issue has disappeared.

relet avatar Oct 01 '18 12:10 relet