Find the latitude and longitude of the saved marker in the flyer

I have a 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 the latitude and longitude of this myMarker.

I tried myMarker.getLatLng(), but it does not work.

+5
source share
2 answers

The problem is not getLatLng (). This works great:

var map = L.map('map').setView([55.4411764, 11.7928708], 13);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <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:

http://jsfiddle.net/pX2xn/2/

+7
source

So you can

$("#One").click(function(){
    var curPos = myMarker.getLatLng();
    alert(curPos.lng + " : " + curPos.lat);
});

this is more detailed.

See a working example here .

+5
source

All Articles