I have a map with 3 geoJson layers representing school district boundaries. The functionality I need is simple: click the map, get a popup with the school names for each level (elementary, middle, and high school.) [eLayer,mLayer,hLayer]
Here's my feature group:
var fGroup = new L.featureGroup([eLayer,mLayer,hLayer]).addTo(map);
I figured I could use the eachLayer method with a click event to get the school name for each polygon at that location. The code below gets me close.
fGroup.on('click',function(e){
fGroup.eachLayer(function(layer){
alert(e.layer.feature.properties.School);
});
});
I only get the name of the last added geoJson layer, which in this case is the high school. I'm a novice programmer, but I researched this for days now and I found one example that sort of had a suggestion, but their solution didn't actually work.
Just to be perfectly clear, I want my output to be like below.
___________________________
| |
|Lincoln Elementary School|
|Tubman Middle School |
|Frederick High School |
|_________________________|