我试图在第一次或任何时候得到最近的标记,但我做不到。在我的代码中,只有当标记打开时我才能得到最近的标记。
这是我的密码:
<body>
<div ng-controller="MyCtrl">
<ng-map
zoom="16"
center="{{address}}"
style="width:500px; height:400px"
scrollwheel = "false">
<marker
position="{{address}}"
title="{{address}}"
on-dragend="getpos($event)"
animation="DROP"
draggable="true">
</marker>
</ng-map>
<br/>Address : <input ng-model="data.dir" />
<input type="button" name="" id="" value="buscar" ng-click="buscar()"/>
<br />
{{data.emp_lat}}-----------{{data.emp_lon}}
</div>
</body>
</html>这是我的js:
angular.module('ngMap').controller('MyCtrl', function($scope) {
$scope.data = {};
$scope.address = 'toronto canada';
$scope.buscar = function(){
$scope.address = $scope.data.dir;
}
$scope.getpos = function(event){
$scope.latlng = [event.latLng.lat(), event.latLng.lng()];
$scope.data.emp_lat = event.latLng.lat();
$scope.data.emp_lon = event.latLng.lng();
};
});我的问题是,当标记掉落时,我怎样才能得到锁?(这应该发生在我输入的地址设置之后)
谢谢朋友们
发布于 2017-09-17 02:26:35
https://developers.google.com/maps/documentation/javascript/reference#Marker
你试过position_changed吗?
https://plnkr.co/edit/0aIlq0iQfQkvU3nreVyY?p=preview
你能试着为下一次创建一个柱塞吗?
注意:您不应该直接将控制器添加到ng-map模块。
https://stackoverflow.com/questions/46248649
复制相似问题