I am using leaflet maps, when I click on the map the map will open a popup in a set place and center on the location using the following code.
var popup = L.popup();
function onMapClick(e) {
popup
.setLatLng([40.737, -73.923])
.setContent("You clicked the map at " + e.latlng.toString())
.openOn(thisLeafletMap);
thisLeafletMap.panTo(new L.LatLng(40.737, -73.923));
}
thisLeafletMap.on('click', onMapClick);
However I want the above code to work when a set html element is clicked rather than the map.
So I was trying something like
$('.lid').click(function() {
//
});
Where .lid is the element to be clicked, but I do not know how to declare the function properly, what would I need to put in the above click function to open the popup as declared in the popup above?
Thank you for any help
to merge them I just put
$('.lid').on('click', onMapClick);
So the query ran when I clicked th div instead of the map
$('#popupid').click();
然后确保你有
data-rel="popup" in your anchor tag....I just looked at some older code of mine that works, It if that does not do the trick Let me know. I will go find what is missing
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.