2015-01-08 31 views
1

我试图使用Angular Google Maps模块在google地图上显示多边形,但当模型的可见属性被修改时,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; 
}; 

我希望,当我改变Visible属性的多边形会显示隐藏。

我不知道我是否发现了一个错误,或者如果我正在尝试不正确地调整多边形的可见性。

编辑:

我提交了一份关于该模块的GitHub的问题回购前几天昨晚得到了解决此问题在2.0.11版本的响应。不幸的是,我使用的是2.0.12版本。

链接到解决该问题的讨论GitHub的:

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

具有相同的问题。你找到什么了吗? –

+0

我前几天在github上提交了一个问题,刚刚得到了回复。评论者找到了可能的解决方案,但它似乎并未解决2.0.12版中的问题。 [问题1059](https://github.com/angular-ui/angular-google-maps/issues/1059) – ALS

回答

0

贡献者nmccready在1月份已经解决了这个问题,但那时我已经放弃了角度谷歌地图。

0

在你的控制器

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

在UI-GMAP多边形.....

visible='showPolygon'