Consider the following Leaflet map construction, which utilizes tiles from OSM and plots two GeoJSON files. The first GeoJSON file is derived from a multipolygon shapefile and the second GeoJSON file is a point shapefile. The relevant code is as follows.
function onEachFeature(feature, layer) { layer.addEventListener("click", () => { layer.bringToFront(); layer.bindPopup(feature.properties.town); }); } var mapstyle = { zoomControl: true, layers: [tileLayer], maxZoom: 14, minZoom: 8 } var polystyle = { color: 'black', // Outline color weight: 2, // Outline width opacity: 1, // Outline opacity (0 to 1) fillOpacity: 0, // Fill opacity (0 to 1) interactive: 'false' } var markeroptions = { radius: 5, fillColor: 'blue', color: '#000000', weight: 1, opacity: 1, fillOpacity: 0.0, interactive: 'true' } var tileLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png'); var map = L.map('map', mapstyle ).on('load', onMapLoad).setView([40.93920434539264, -73.86905931034256], 11); fetch('link/to/file/points.json') .then(response => response.json()) .then(data => { L.geoJSON(data, {style: polystyle}).addTo(map); }); fetch('link/to/file/points.json') .then(response => response.json()) .then(data => { L.geoJSON(data, { pointToLayer: function (feature, latlng) { return L.circleMarker(latlng, markeroptions); }, onEachFeature: onEachFeature }).addTo(map); }); function onMapLoad(){ console.log("map loaded"); } The entirety of this code produces the desired result, with the exception of the bindPopup at each circleMarker centroid. The issue I'm facing is that these popups do not fire when clicking on a point located inside a layer polygon. This issue looks as follows, note that the popup successfully fires over a point outside the polygon GeoJSON, but fails to do so just to the east:
What corrections can be made to the code above to allow popup events to fire on circleMarkers found inside the boundaries of any particular polygon?
