Abdulaziz Busbate Abdulaziz Busbate - 1 year ago 73
AngularJS Question

How do I access the current location (lat, lng) of a map marker using ngMap in Angularjs?

I have an Angularjs website that requests geolocation from users using ngMap. Take a look at this plunker.

<map center="current-location" zoom="16">
<marker visible="true" centered="true" position="current-location" title="You are Here" draggable="true"></marker>

It works fine but how can I access (save or print) the current location or the marker's location after it's been dragged to a different place?

Answer Source

Here is a way to access a marker's location (lat, lng).

$scope.$on('mapInitialized', function(evt, evtMap) {
    $scope.map = evtMap;
  $scope.showMarkerLatlng = function(){