Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
135
rated 0 times [  139] [ 4]  / answers: 1 / hits: 124662  / 12 Years ago, thu, june 14, 2012, 12:00:00

I'm using Google Maps API. And I'm using the code below to get the coordinates of the marker.



var lat = homeMarker.getPosition().$a;
var lng = homeMarker.getPosition().ab;


Everything is working fine with the app that I built using Google Maps.
But I tested it today and I got problems getting the correct coordinates. Only to discover that the code above is getting undefined. After I console.log(homeMarker.getPosition()) I discovered that this is now the variables that they used for the coordinates.



var lat = homeMarker.getPosition().ab;
var lng = homeMarker.getPosition().cb;


I won't ask why Google Maps acts this way but you can also include it in your answer. My question is that how do I properly get the coordinates without changing my code everytime google maps changes the variables that they're using.


More From » google-maps

 Answers
4
var lat = homeMarker.getPosition().lat();
var lng = homeMarker.getPosition().lng();


See the google.maps.LatLng docs and google.maps.Marker getPosition().


[#84914] Wednesday, June 13, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
trayvon

Total Points: 35
Total Questions: 117
Total Answers: 88

Location: Guernsey
Member since Tue, Jul 6, 2021
3 Years ago
;