Getting coordinates of marker in Google Maps API
google-maps, javascript
Solution
var lat = homeMarker.getPosition().lat();
var lng = homeMarker.getPosition().lng();
See the google.maps.LatLng docs and google.maps.Marker `getPosition()`.
Problem
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.