find latitude & longitude of saved marker in leaflet
30,890
Solution 1
The problem does not lie in getLatLng(). This works fine:
var map = L.map('map').setView([55.4411764, 11.7928708], 13);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
var stuSplit = L.latLng(55.4411764, 11.7928708);
var myMarker = L.circleMarker(stuSplit,
{ title: 'unselected' })
.addTo(map);
alert(myMarker.getLatLng());
See a working example here:
Solution 2
So you can
$("#One").click(function(){
var curPos = myMarker.getLatLng();
alert(curPos.lng + " : " + curPos.lat);
});
this in more detail.
See a working example here.
Author by
vaibhav shah
Updated on July 21, 2022Comments
-
vaibhav shah almost 2 years
I have circle marker
var myMarker = L.circleMarker(stuSplit, { title: 'unselected' }) .bindLabel("Name: " + students[i][j][0] + " ReachTime: " + students[i][j][2]);
Now I want to find latitude & Longitude this myMarker.
I was trying
myMarker.getLatLng()
but it is not working. -
vaibhav shah about 11 yearsbindLabel is plugin which I am using
-
flup about 11 yearsUnderstood. Updated answer. That leaves the question what we are doing different then, cause it works fine for me.