Angular UI Google 地图中心标记

Angular UI Google Maps center marker

我正在使用 Angular(UI)-Google-Maps (2.1.5) 和 AngularJS (1.3.13)

我想要一个始终位于地图中心的标记。问题是标记只会在我停止拖动时更新其位置。

我是这样使用拖动事件的:

drag: function(maps) {     
    $scope.map.marker.center.coords = $scope.map.center;
}

我还统计了数量,拖动事件触发的频率,比标记(或地图)的更新要高得多。这是一个示例:http://plnkr.co/edit/M39CFc

我也尝试了 center_changedbounds_changed,结果相同。

要将标记放在地图的中心,请使用以下标记:

<ui-gmap-marker coords="map.center" idkey="1" ng-cloak>

尽管不鼓励使用此技术,因为它也会在拖动地图时移动标记。要解决这种情况,请使用:

marker.coords = Object.create(coords)

另一种可能性是将 属性 draggable = true 添加到标记中:

 <ui-gmap-markers coords="'self'" icon="'icon'" options="{ draggable: true }">

不知道为什么这解决了 IE 中的问题,check this