-
Notifications
You must be signed in to change notification settings - Fork 195
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
Problem with Leaflet >= 1.8 #274
Comments
TL;DR: I solved this by changing to svg renderer instead of canvas renderer with rendererFactory option. Issue is due to a change in Leaflet 1.8 due to this issue, Leaflet/Leaflet#7431 I think that this kind of issues is why the author of Leaflet.VectorTileLayer opted for another design. As he writes: "In contrast to VectorGrid, this class has been designed as much as possible in terms of Leaflet's public API." |
I have used:
additional code:
vtLayer2.on('click', function(e) {
|
I was able to solve this by including the following code before any use of L.VectorGrid code. This overwrites the place in the codebase where L.Canvas.Tile.include({
_onClick: function (e) {
var point = this._map.mouseEventToLayerPoint(e).subtract(this.getOffset());
var layer: L.Layer;
var clickedLayer: L.Layer;
for (var id in this._layers) {
layer = this._layers[id];
if (
layer.options.interactive &&
layer._containsPoint(point) &&
!this._map._draggableMoved(layer)
) {
clickedLayer = layer;
}
}
if (clickedLayer) {
// offending code used to be right here
clickedLayer.fireEvent(e.type, undefined, true);
}
},
}); |
Hi there,
I'm using VectorGrid and trying to catch the click event on one of my feature/vectorgrid using following code:
vectorGrid.on('click', function(e) {
L.popup()
.setContent("test")
.setLatLng(e.latlng)
.openOn(map);
}
It works perfectly fine with Leaflet 1.7.1 but crashes with Leaflet 1.8+. I get the following error when the click happens:
Uncaught TypeError: L.DomEvent.fakeStop is not a function
at NewClass._onClick (Leaflet.VectorGrid.bundled.min.js:2:15768)
at HTMLCanvasElement.handler (DomEvent.js:108:13)
Leaflet.VectorGrid.bundled.min.js:2
Strangely, the "mouseover" event is working fine.
Any idea on how to get it working?
Thanks a lot
Sam
The text was updated successfully, but these errors were encountered: