I host a leaflet map and want to link to certain marker on that map from an a-element outside the map. I want the marker to behave like it was clicked, when the link is clicked.
Clicking on
<a href="#" onclick="WHATGOESHERE?">My Link</a>
should activate my marker
L.marker([52.121935,11.627137], {icon: photomarker}).addTo(map)
.bindPopup("<b>This is a marker</b>") ;
How can I achieve that? I got a hint, that it can be done with
marker.fire('click')
but I dont get it. Where should I put that? I am pretty new to javascript...
You can see the whole map here: http://bit.ly/VtFXFN
save reference
var t = L.marker([52.121935,11.627137], {icon: photomarker}).addTo(map)
.bindPopup("<b>This is a marker</b>");
in a
<a href="#" onclick="t.fire('click')">My Link</a>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.