Get Lat Long from click event on map
Might just be a misunderstanding, but I'm trying to get the coords from the point a user clicks on. Looks simple enough with the reggie gmap API v3 with something like:
google.maps.event.addListener(map, 'click', function(event) {
var myLatLng = event.latLng;
var lat = myLatLng.lat();
var lng = myLatLng.lng();
})
I've wired up a click function to the directive as so:
$scope.mapEvents = {"click":function(event){
console.log(event)
}
}
However, the returned event doesn't appear to have a lat() and lng() method. Ive been digging through the properties of the object and its quite a beast. Any ideas?
(always think of something AFTER I post an issue)
I was able to get the lat long by checking any other returned data, which indeed it does. The click event will return an array as a third argument, containing lat lng at the first index.
Hope this helps anyone who runs into the same question.
If there is another or preferred way, do tell!