0

This is a cross-post from SO. I am trying to use Leaflet VectorGrid interactivity option for click and mouse events:

const vectorGrid = L.vectorGrid.slicer(geoJsonDocument, {
    rendererFactory: L.canvas.tile,
    vectorTileLayerStyles: {
      sliced: geoJSONStyle(false)
    },
    maxZoom: 22,
    indexMaxZoom: 5, // max zoom in the initial tile index
    interactive: true
  });

  vectorGrid.on("mouseover", function (e) {
    console.log("mouseover");
  });

  vectorGrid.on("click", function (e) {
    console.log("click");
  });

However, interactivity doesn't work if Leaflet.markercluster is used.

I created a codesandbox.

If you comment map.addLayer(mcg);, interactivity works.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.