2016-03-15 90 views

回答

3

你可以做到这一点这种方式,也可以得到甚至标记拖动坐标:

<ng-map on-click="getpos($event)"> 
    <marker ng-repeat="p in positions" 
     position="{{p}}" on-dragend="getpos($event)"> 
    </marker> 
</ng-map> 

,并在你的控制器:

$scope.getpos = function(event) { 
    console.log(event.latLng); 
}; 

小提琴:fiddle

更新:with initialize

编辑我会尝试

改变你的js

app.run(function(editableOptions) { 
    editableOptions.theme = 'bs3'; 
}); 

app.run(function(editableOptions, $rootScope) { 
    editableOptions.theme = 'bs3'; 
    $rootScope.$on('mapInitialized', function(evt,map) { 
     $rootScope.map = map; 
     $rootScope.$apply(); 
    }); 
}); 
+0

不工作....! –

+0

太棒了,把它标记为答案。 :P ...它应该...别的东西不工作...创建一个小提琴。 – daniel

+0

https://ngmap.github.io/#/!marker-animations.html =>查看此页面。我的项目也是这样。 –

1

在谷歌米初始化aps:

var latlngbounds = new google.maps.LatLngBounds(); 
google.maps.event.addListener(map, 'click', function (e) { 
alert("Latitude: " + e.latLng.lat(); + "\r\nLongitude: " + e.latLng.lng());