Following this tutorial on how to get custom tooltips on Leaflet.markercluster popups and I don’t understand how the marker attributes are built with a.layer._markers[feat].feature.properties['name']
, as I don’t know how to refer to the relevant text / property in my code. Their eg, simplified:
markers.on('clusterclick', function(a){
popUpText = '<ul>';
for (feat in a.layer._markers){
popUpText+= '<li>' + a.layer._markers[feat].feature.properties['name'] + '</li>';
}
popUpText += '</ul>';
var popup = L.popup().setLatLng([a.layer._cLatLng.lat, a.layer._cLatLng.lng]).setContent(popUpText).openOn(map);
})
The browser shows “Uncaught TypeError: a.layer._markers[feat].feature is undefined”, and this is the only time the tutorial refers to a.layer._markers[feat].feature.properties['name']
. My code for non cluster popups:
var addressPoints = [
[36.942, 69.902, "a"],
[36.946, 69.911, "b"],
[36.943, 69.909, "c"],
]
for (var i = 0; i < addressPoints.length; i++) {
var a = addressPoints[i];
var title = a[2];
var marker = L.marker(new L.LatLng(a[0], a[1]), {title: title});
marker.bindPopup(a[2]);
markers.addLayer(marker);
}
map.addLayer(markers);
I can’t find it through seemingly any variation of a.layer_markers[whatever]
. How can I adjust their example to get the equivalent a.layer._markers[feat].feature.properties['name']
from my markers
? Or how can I troubleshoot this by finding the properties of a.layer_markers[whatever]
to make the tooltip display “a”, “b”, or other properties provided in addressPoints
?