I have an application that uses leaflet.js and geoJSON to create a large polygon area that then gets populated with smaller circles using a mix of jQuery and leaflet.js.
This is where the circles are created:
$.getJSON('http://localhost/json/json.php', function(data){
$(data.payload.incidents).each(function(key, value) {
var lati = data.payload.incidents[key].incident.locationlatitude;
var longi = data.payload.incidents[key].incident.locationlongitude;
var title = data.payload.incidents[key].incident.incidenttitle;
var desc = data.payload.incidents[key].incident.incidentdescription;
var mark = L.circle([lati, longi], 50,{
color: 'red',
fillColor: '#f03',
fillOpacity: 0.5
}).addTo(map);
mark.bindPopup("<b>"+title+"</b></br></br>"+desc).openPopup();
console.log("success");
}
})
});
I have tried to use this line of code to detect the circles:
if(geojson.getBounds().contains(mark){console.log('mark detected')}
but .contains() appears only to be used for rectangles.
This is where the polygons are added to the map. (areaData is geoJSON)
var geojson
geojson = L.geoJson(areaData, {
style: style,
onEachFeature: onEachFeature
}).addTo(map);