I do have a point layer (data from a GeoJSON) and a polygon layer (also GeoJSON) in Leaflet. Both layers are created the same way and I made both layers "non-interactive". Unfortunately the point layer still reacts on the click-event on the point. The polygon layer is working just fine. Is this a bug or a feature?

Both layers are defined like this:

var layer = L.geoJson(json_data, {
            interactive: false

My goal is to set the points to "non-clickable" aka non-interactive as well. A working example is given here: https://codepen.io/butcher/pen/dBpWRP


Problem comes from different nature of point and polygon representation.

Polygon is represented by itself and when you set interactive option for polygon to false, it becomes noninteractive.

Point is represented by marker and when you set interactive option for point to false, attached default marker stays interactive. You have to use pointToLayer option for defining your own noninteractive marker, something like this:

function pointToLayer(point, latlng) {
    return L.marker(latlng, {interactive: false});
var layer_airports_0 = new L.geoJson(json_airports_0, {
    pointToLayer: pointToLayer
  • You don't need to set the layer to "interactive:false". The declaration at the marker level suits just well. – Riccardo Jun 18 at 19:50
  • 1
    I know, it was just copy/paste of original code from codepen. – TomazicM Jun 19 at 5:24

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.