Leaflet / Leaflet.VectorGrid

Display gridded vector data (sliced GeoJSON or protobuf vector tiles) in Leaflet 1.0.0
598 stars 194 forks source link

When loading multiple layers with interactive: true, only the one added last becomes interactive #88

Closed brendanvinson closed 7 years ago

brendanvinson commented 7 years ago

We're loading multiple pbf layers as properties of the same map with { interactive: true } set on both. Unfortunately, it seems like the only the one that's added last to the map becomes interactive. Our Leaflet version is 1.0.3.

ddproxy commented 7 years ago

Clarification - the top visible layer is interactive and thus displays the proper data - the layers underneath are ignored even if the top visible layer does not have a geometry in that location.

perliedman commented 7 years ago

I'm going to guess that you're using the canvas renderer.

The problem is that you can't click through a canvas, only the top most canvas will get mouse events.

You can see http://www.vinylfox.com/forwarding-mouse-events-through-layers/ for a hack around this, but this is not fixable in VectorGrid.

brendanvinson commented 7 years ago

I'm using the SVG renderer, not canvas. I'm also getting a "connection timed out" trying to load that page.

perliedman commented 7 years ago

@brendanvinson ok, I think you want this fix: https://github.com/Leaflet/Leaflet.VectorGrid/pull/75 - I don't think it's in a released version, though, which might be why you're still seeing the issue.

brendanvinson commented 7 years ago

That looks promising, any idea when it will be released since it's in master? Failing that I guess I could clone the repo and then bundle everything in master manually and use that.

ddproxy commented 7 years ago

@perliedman Curious why there are no tags for releases on this project. I can scroll through the package releases and tag them if that was an oversight.

IvanSanchez commented 7 years ago

@ddproxy We haven't paid much attention to release tags in this repo, so feel free to do that. See also https://github.com/hypermodules/gh-release , might make things easier.

ddproxy commented 7 years ago

@IvanSanchez thanks! Looking at gh-release, it seems to be primarily for current release cycles not identifying historical. Something to look into for the future, however.

IvanSanchez commented 7 years ago

You should be able to git blame the package.json file, see which commits did the version bump, then git checkout {commit}, then gh-release. Not sure if it's the best way to do past releases.

brendanvinson commented 7 years ago

I cloned the repo and did a local build on master and can confirm that this issue is fixed. Thanks!

m0ose commented 7 years ago

Can you tell me how you got it to work? I am using master branches and it still it fails to poss the mouse to lower layers. The workaround/hack I am using is

Array.from(vectorific.getElementsByTagName('svg')).forEach((a)=>{a.style.pointerEvents = 'none'})
Array.from(vectorific.getElementsByTagName('path')).forEach((a)=>{a.style.pointerEvents = 'auto'})
victorbucutea commented 7 years ago

Doesn't work here either. I'm using the canvas rendering. Multiple layers sit on top of each other preventing the ones on the bottom to receive clicks.

perliedman commented 7 years ago

@victorbucutea see this comment regarding multiple canvas layers: https://github.com/Leaflet/Leaflet.VectorGrid/issues/88#issuecomment-284350575