elmarquis/Leaflet.GestureHandling

Map sometimes not draggable when reloading the Website

Opened this issue · 4 comments

Hi there,

I have the Problem that the Map sometimes is not draggable when I reload the Website with STRG +R or STRG + SHIFT + R. The cursor switches not to the hand symbol but remains as an arrow.

I can't see any error in the console output and there is absolutely no recognizable pattern. A few times it works and suddenly it doesn't.

When i disable the plugin all works fine. I'm using the latest version.

Any Ideas?

Thank you :)

Same issue here. Did you found a solution for it?

tfilo commented

Same issue here. Any updates ?

One thing I noticed is when I have a polygon layer on the map, clicking and dragging on the polygon works to pan the map, but clicking off of a polygon and trying to drag does not work. Behavior resolves when I disable this plugin. Not sure if that is related.

A workaround is calling _handleMouseOver once gestureHandling is initialized, for instance via map.whenCreated

// react-leaflet
<MapContainer
  gestureHandling={true}
  whenCreated={map => {
    // Workaround for https://github.com/elmarquis/Leaflet.GestureHandling/issues/75
    map.gestureHandling?._handleMouseOver?.();
  }}
>
// untested
var map = L.map("map", {
  center: [-25.2702, 134.2798],
  zoom: 3,
  gestureHandling: true,
});
// Workaround for https://github.com/elmarquis/Leaflet.GestureHandling/issues/75
map.whenReady(() => map.gestureHandling?._handleMouseOver?.());