I add a bunch of layers to my map, using a set of geoJSON objects (actually UK post code areas) - these show up nicely.
After that, I add a set of markers at specified locations.
What I want to do now is iterate through these markers and find out which post code area they belong to - ie in which of the first set of layers they fall in.
I can loop through the markers thus:
var ll;
map.eachLayer(function (mrk) {
if (mrk instanceof L.Marker) {
// ll = mrk.getLatLng();
// this is a LatLong object, for whatever use that is...
}
});
but can't figure out how (if) I can get what I want from here... is there aa way of finding a "parent" layer? Except this isn't a strict parent in the DOM sense, of course... I'm just wondering if there's a way of saying "Ah, marker X is sitting on top of layer Y" (Or, maybe, the other way round: loop through the base layers and find out which markers sit on each.)
Probably not. I suspect I may have to approach this whole problem differently, not using Leaflet at all...