I've been trying to incorporate markers and eventually make it so I can click on one and it will open more markers as you click through but I can't seem to click on markers after clicking the first one.
It also opens up the latest marker wherever I click and after I close it, I'm still unable to open another.
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
attribution: 'Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 10,
id: 'mapbox/streets-v11',
tileSize: 512,
zoomOffset: -1,
accessToken: 'pk.eyJ1Ijoicml0emJpdHoiLCJhIjoiY2txbjA5dzBlMDM5bTJ2cDVlbTIzb3pjeiJ9.Al3vqwu8sCDVxwzU0RakUw'
}).addTo(mymap);
var seddulbahirMarker = L.marker([40.0429, 26.1889]).addTo(mymap);
var seddulbahirPopup = L.popup()
.setLatLng([40.0429, 26.1889])
;
function onMapClickSeddul(e) {
seddulbahirPopup
.setContent("This was one of the first points <br> of attack on the map")
.openOn(mymap);
}
mymap.on('click', onMapClickSeddul);
var kumkumMarker = L.marker([39.9806, 26.2379]).addTo(mymap);
var kumkumPopup = L.popup()
.setLatLng([39.9806, 26.2379])
;
function onMapClickKumkum(e) {
kumkumPopup
.setContent("This was one of the first points <br> of attack on the map")
.openOn(mymap);
}
mymap.on('click', onMapClickKumkum); ```
Aucun commentaire:
Enregistrer un commentaire