I am using this code to draw points on the map:
coordsArray.push(lat);
coordsArray.push(lng);
marker = L.marker(coordsArray, {
icon: myIcon,
clickable: true,
draggable: 'false',
title: layerStringToJson.properties.id
}).bindPopup(coordinates).addTo(map).on('click', onClick);
And I have this method to get individual marker properties:
function onClick(e) {
//marker=layerStringToJson.properties;
console.log(marker._latlng)
}
But when I click on the markers, I always have the same result, always the same coordinates instead of the coordinates of every single marker.
Anyway the pop up shows the correct coordinates.
How can I get the individual properties of each marker?
console.log(e)
) and also stackoverflow.com/questions/111102/… (think about what's the value ofmarker
then the event handler runs).