Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why can't I click the feature when I add 2 Leaflet.VectorGrid layer? #242

Open
liyihongcug opened this issue Jul 4, 2020 · 2 comments
Open

Comments

@liyihongcug
Copy link

I have to point out that Leaflet.VectorGrid is OK when Leaflet.VectorGrid handle with one vectorTile address.
It can click all the feature's properties of the Leaflet.VectorGrid layer.

But when I add many Leaflet.VectorGrid layer. layers address (for examples ,2 Leaflet.VectorGrid layers).
It fails that only one layer's feature can be clicked and others can't be clicked.

all the layers are configured with interactive: true by me.
I want to know the reason and how to solve with it .

codes are below :(only one (pbfLayer1,pbfLayer2) can be clicked and the other can't be clicked )
var cs1TileOptions = {
rendererFactory: L.canvas.tile,
vectorTileLayerStyles: {
'cs1: {
weight: 1.......
}
},
interactive: true,
getFeatureId: function(f) { return f.properties.OBJECTID; }
};
v ar pbfLayer1= L.vectorGrid.protobuf(...cs1TileOptions
pbfLayer1.on('click', function (e) {
var properties = e.layer.properties; //console.log(e);
L.popup().setContent('lvhua'+properties.名称+properties.地址+''+ properties.OBJECTID) .setLatLng(e.latlng) .openOn(map);
});

var cs2TileOptions = {
rendererFactory: L.canvas.tile,
vectorTileLayerStyles: {
'cs2: {
weight: 1.......
}
},
interactive: true,
getFeatureId: function(f) { return f.properties.OBJECTID; }
};
v ar pbfLayer2= L.vectorGrid.protobuf(...cs2TileOptions
pbfLayer2.on('click', function (e) {
var properties = e.layer.properties; //console.log(e);
L.popup().setContent( properties.OBJECTID) .setLatLng(e.latlng) .openOn(map);
});

@Hugi-R
Copy link

Hugi-R commented Jul 21, 2020

Hi !
Your layers are canvases, and you can't click through a canvas. See #88 (comment)

If possible, use the SVG renderer for the layer with the least elements, and put it above the canvas layer.

@mngyng
Copy link

mngyng commented Mar 24, 2022

Actually you can. See my workaround here:
https://gist.github.com/perliedman/84ce01954a1a43252d1b917ec925b3dd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants