Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find latitude & longitude of saved marker in leaflet

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.

like image 508
vaibhav shah Avatar asked Apr 16 '13 12:04

vaibhav shah


People also ask

How do I find the location of latitude and longitude?

To find a location using its latitude and longitude on any device, just open Google Maps. On your phone or tablet, start the Google Maps app. On a computer, go to Google Maps in a browser. Then enter the latitude and longitude values in the search field — the same one you would ordinarily use to enter an address.

How do you find the latitude of a line?

Use the sight line on the top of the aiming beam to align the beam with the North Star. Use the protractor to measure the angle between the beam and the horizon (which is 90º to the plumb line). This angle is your latitude.

Can Google Maps find latitude longitude?

Open 'Google Maps': Open maps.google.com in your browser. Click on the search bar: Now click on the search bar at the top left corner. Enter the latitude and coordinates: Now enter the latitude and longitude in Google maps.


1 Answers

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: '&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/

like image 148
flup Avatar answered Oct 30 '22 05:10

flup