【问题标题】:Retrieving map markers - angular google maps检索地图标记 - 角度谷歌地图
【发布时间】:2015-10-11 12:34:40
【问题描述】:

如何使用角度谷歌地图检索标记集合? 我尝试使用var markers = $scope.map.markerscontrol.getGMarkers();,但它只返回列表中的最后一项。

做了一个小程序http://plnkr.co/edit/Tl60bVydDQ3jIXqG6nIc

我想使用标记来计算边界和地图中心。

【问题讨论】:

  • 即使我也有这个问题。你能度过难关吗?

标签: angularjs angular-google-maps


【解决方案1】:

我认为它对你有帮助。

在您的 HTML 文件中:

<ui-gmap-google-map center="map.center" zoom="map.zoom" options="options" data-tap-disabled="true">
    <ui-gmap-marker 
      icon="yourModel.icon"
      idKey="yourModel.id"
      coords="yourModel.coords"
      control="markerControl">
    </ui-gmap-marker>
</ui-gmap-google-map>

在你的角度控制器中。

$scope.yourModel = {
  id: 1,
  coords = {
    latitude: position.latitude,
    longitude: position.longitude
  },
  icon = 'path/to/icon.png'
};
$scope.markerControl = {};

以及如何使用

var marker = $scope.markerControl.getGMarkers();
// marker variable, get an array of object to use.

【讨论】:

    猜你喜欢
    • 2014-09-02
    • 1970-01-01
    • 2018-10-13
    • 2020-08-18
    • 1970-01-01
    • 1970-01-01
    • 2017-03-29
    • 2017-10-09
    • 1970-01-01
    相关资源
    最近更新 更多