I am using OSM with leaflet API. Now I want to get the lat and long of a clicked location. I meant something similar to this:
http://openlayers.org/dev/examples/click.html
map.events.register("click", map, function(e) {
var position = map.getLonLatFromPixel(e.xy);
alert("Lat, Lon : "+position.lon.toFixed(3),position.lat.toFixed(3));
});
This code in open layers helps to get the lat,long values - looking for something similar using leaflet.
Any help would be really great. Thanks in advance
Show current user location The leaflet can also show the view based on the current location by using locate() method. It takes in an object that has setView property set to true and a maxZoom value set to a maximum value. This command will ask for the user's location and automatically set the view to that location.
On the Google Maps app, you can't pull up a context menu. To find the address for your coordinates, hold your finger down over the red pin that shows your coordinates. Then, after 1-3 seconds, the address will pop up on the bottom of your screen.
Represents a geographical point with a certain latitude and longitude.
map.on('click', function(e) {
alert(e.latlng);
});
Docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With