Search code examples
javascriptangularjsgoogle-maps-api-3ng-map

How to get ng-map marker position after dragend?


I'm using ng-map for Angularjs, I'm using the following code to get marker position after drag event

<div class="mapWrap"   data-tap-disabled="true">

        <map center="43.07493,-89.381388" zoom="4"> 

          <marker draggable=true position="{{pos.lat}},{{pos.lng}}" 
          on-dragend="getCurrentLocation()"></marker>    
        </map>

$scope.getCurrentLocation = function(){

     $scope.pos = this.getPosition();
     concole.log($scope.pos.lat() +' '+ $scope.pos.lng());
}

But its not working. Any suggestions?


Solution

  • Just get it from the event of on-dragend:

    $scope.getCurrentlocation = function(e) {
        $scope.address.lat = e.latLng.lat();
        $scope.address.lng = e.latLng.lng();
    };
    

    At least this works for me.