【问题标题】:How to get ng-map marker position after dragend?拖动后如何获取 ng-map 标记位置?
【发布时间】:2016-02-14 17:08:26
【问题描述】:

我正在为 Angularjs 使用 ng-map,我正在使用以下代码在拖动事件后获取标记位置

<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());
}

但它不起作用。有什么建议吗?

【问题讨论】:

  • on-dragend 是否代表 ng-map 的有效事件?如果是的话,还有什么选择?
  • 文档不会告诉你吗?
  • 从另一个问题而不是从文档中得到它?这是链接link

标签: javascript angularjs google-maps-api-3 ng-map


【解决方案1】:

只要从 on-dragend 事件中得到它:

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

至少这对我有用。

【讨论】:

  • 它对我不起作用。你也可以提供HTML5吗?
  • 我使用了原始问题中的标记。确保将可拖动属性设置为 true
猜你喜欢
  • 2016-03-13
  • 2018-06-01
  • 2017-09-16
  • 1970-01-01
  • 1970-01-01
  • 2017-10-07
  • 2016-04-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多