【问题标题】:Polygons directive not respecting the visible property多边形指令不尊重可见属性
【发布时间】:2015-01-08 18:38:17
【问题描述】:

我正在尝试使用Angular Google Maps 模块在谷歌地图上显示多边形,但是当模型的可见属性被修改时,uiGmapPolygons 指令没有隐藏/显示。

这里有一个 plunker 来说明这个问题: http://plnkr.co/edit/EhFihJRBK9Lb0s3mwMSl

标记:

<ui-gmap-google-map center="map.center" zoom="map.zoom" draggable="true" options="options" bounds="map.bounds">
    <ui-gmap-polygons models="polygons" path="'path'" stroke="'stroke'" visible="'visible'" fill="{ color: '#2c8aa7', opacity: '0.3' }">
    </ui-gmap-polygons>
     <ui-gmap-markers models="markers" idKey="'id'" options="'options'" coords="'coords'"></ui-gmap-markers>        
</ui-gmap-google-map>

角度代码:

$scope.polygons = [{
  id: 1,
  path: [{
    latitude: 50,
    longitude: -80
  }, {
    latitude: 30,
    longitude: -120
  }, {
    latitude: 20,
    longitude: -95
  }],
  stroke: {
    color: '#6060FB',
    weight: 3
  },
  editable: true,
  draggable: true,
  geodesic: false,
  visible: true,
  fill: {
    color: '#ff0000',
    opacity: 0.8
  }
}];

$scope.toggle = function() {
  $scope.polygons[0].visible = !$scope.polygons[0].visible;
  $scope.markers[0].options.visible = !$scope.markers[0].options.visible;
};

我希望当我更改多边形将显示/隐藏的可见属性时。

我不确定我是否发现了错误,或者我是否试图错误地调整多边形的可见性。

编辑:

几天前我在模块的 github repo 上提交了一个问题,昨晚得到了回复,解决了 2.0.11 版本中的问题。不幸的是,我使用的是 2.0.12 版本。

关于该问题的 github 讨论链接:

https://github.com/angular-ui/angular-google-maps/issues/1059

【问题讨论】:

  • 有同样的问题。你有什么发现吗?
  • 我前几天在github上提交了一个issue,昨天刚收到回复。评论者找到了可能的解决方案,但似乎无法解决 2.0.12 版本中的问题。 Issue 1059

标签: angularjs google-maps-api-3 angular-google-maps


【解决方案1】:

在你的控制器中

$scope.showPolygon = false;
$scope.toggelPolygon = function(){$scope.showPolygon=!$scope.showPolygon};

在你的 ui-gmap-polygon .....

visible='showPolygon'

【讨论】:

    【解决方案2】:

    贡献者 nmccready 早在一月份就修复了这个问题,但那时我已经放弃了 angular-google-maps。

    【讨论】:

      猜你喜欢
      • 2011-08-19
      • 1970-01-01
      • 2016-07-30
      • 2013-01-10
      • 2016-01-07
      • 2016-11-09
      • 2012-01-11
      • 2011-01-11
      • 1970-01-01
      相关资源
      最近更新 更多