Simple example of how to send marker ID to a PHP page
var map = L.map("map").setView([48.86, 2.35], 12);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© http://osm.org/copyright">OpenStreetMap> contributors'
}).addTo(map);
var myFeatureGroup = L.featureGroup().addTo(map).on("click", groupClick);
var marker, test;
for (var i = 0; i < 20; i += 1) {
test = " link ";
marker = L.marker(getRandomLatLng()).addTo(myFeatureGroup).bindPopup(test);
marker.test = test;
}
function groupClick(event) {
console.log("Clicked on marker " + event.layer.test);
}
function getRandomLatLng() {
return [
48.86 + 0.1 * Math.random() - 0.05,
2.35 + 0.1 * Math.random() - 0.05
];
}
No comments:
Post a Comment