Javascript NgMap可拖动位置

Javascript NgMap可拖动位置,javascript,jquery,angularjs,google-maps,Javascript,Jquery,Angularjs,Google Maps,我想知道地图的可拖动位置。我在ng map上设置了dragend,但是事件没有返回位置,因为地图本身没有位置。我计划在地图中心创建隐藏的自定义标记。拖动地图时,标记也将被移动/拖动。调用on dragend时,该隐藏自定义标记的当前位置将相应更新 我怎样才能做到这一点 查看 <ng-map center="{{ latitude }}, {{ longitude }}" zoom="14" on-dragend="dragEnd()">

我想知道地图的可拖动位置。我在ng map上设置了dragend,但是事件没有返回位置,因为地图本身没有位置。我计划在地图中心创建隐藏的自定义标记。拖动地图时,标记也将被移动/拖动。调用on dragend时,该隐藏自定义标记的当前位置将相应更新

我怎样才能做到这一点

查看

<ng-map center="{{ latitude }}, {{ longitude }}" 
          zoom="14" 
          on-dragend="dragEnd()">
    <marker icon="{{customIcon}}" position="{{ latitude }}, {{ longitude }}">
    </marker>
</ng-map>
根据
dragend
事件不接受任何参数:

参数:无当用户停止拖动 地图

<>你可以考虑基于当前的地图属性更新标记(例如,在地图被拖动时,通过使用图的中心使用<代码> GETCenter()/代码>函数:

$scope.dragEnd = function () {
   $scope.pos = [$scope.map.getCenter().lat(),$scope.map.getCenter().lng()];
};
范例

angular.module('plunker',['ngMap']))
.controller('MainCtrl',['$scope','NgMap',
功能($scope,NgMap){
NgMap.getMap().then(函数(map){
$scope.map=map;
});
$scope.center=[45.026950,15.205764];
$scope.pos=[45.026950,15.205764];
$scope.dragEnd=函数(){
$scope.pos=[$scope.map.getCenter().lat(),$scope.map.getCenter().lng()];
};
}]);

dragend
$scope.dragEnd = function () {
   $scope.pos = [$scope.map.getCenter().lat(),$scope.map.getCenter().lng()];
};