How to get lat and long on click?
See original GitHub issueI just tried
$(".mapcontainer").data('mapael').mapPagePositionToXY(e.pageX, e.pageY)
. I am getting the x and y co-ordinates which I am saving into database. And showing it somewhere. Now, I want to save the lat and long into database and show the same. How can I get the lat and long from the clicked position?
Currently, I am using this to get the current x and y position.
$(".mapcontainer").on('click', function (e) {
var coords = $(".mapcontainer").data('mapael').mapPagePositionToXY(e.pageX, e.pageY), plotId = 'plot-' + Math.round(Math.random() * 1000), updateOptions = { 'newPlots': {}, 'replaceOptions': { resetPlots: true }, deletePlotKeys: plots };
plots.push(plotId);
updateOptions.newPlots[plotId] = {
x: coords.x,
y: coords.y,
value: "unknown"
};
selectedlat = coords.x;
selectedlong = coords.y;
ReInitialize(updateOptions);
});
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Getting Lat/Lng from a Click Event | Maps JavaScript API
To navigate, press the arrow keys. Click the map to get Lat/Lng! zoom: 4, center: myLatlng,
Read more >how to get latitude, longitude onclick of a map in google maps ...
You have to use event argument. google.maps.event.addListener(map, 'click', function(event) { marker = new google.maps.
Read more >Getting Lat, Long of clicked location using Leaflet API?
You can easily get click events using the map's 'on' event subscription method: map.on('click', function(e) { alert("Lat, ...
Read more >Calculating a Location from a Mouse Click - Maps API for ...
Obtain the latitude and longitude of a location within the map. ... The tap event holds the x and y screen coordinates of...
Read more >Google Maps: Get Latitude/Longitude value on Click and on ...
This article shows how to get latitude and longitude value when you click or move the mouse over Google Map.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think adding that function should give the more flexibility to this tool. This way the users will directly get an idea what they need to do to achieve something. I spent a whole day finding this out 😃
You’re right, at least a little bit of documentation would be welcome on this topic 😃