目的在地图上显示一堆随机标记。单击其中之一时,打开一个信息窗口。我使用了API页面(标记)中的示例之一,并添加了窗口的标记和单击处理程序方法以显示窗口。我只是无法使其工作
问题显示标记,但单击时未显示任何窗口。
另外,在使用tag和ng-repeat时,我可以进行此工作;但是文档说标记是首选方法。
有任何想法吗?
此处的示例:https : //angular-ui.github.io/angular-google-maps/#!/api
在这里插入:http ://plnkr.co/edit/ze7EKMQNV7MLGkmlhiAC
<div id="map_canvas" ng-controller="mainCtrl">
<google-map center="map.center" zoom="map.zoom" draggable="true" options="options" bounds="map.bounds">
<markers models="randomMarkers" coords="'self'" icon="'icon'" click="'onClicked'">
<window ng-cloak show="'showWindow'">
<h1>{{title}}!</h1>
</window>
</markers>
</google-map>
</div>
$scope.$watch(function() {
return $scope.map.bounds;
}, function(nv, ov) {
// Only need to regenerate once
if (!ov.southwest && nv.southwest) {
var markers = [];
for (var i = 0; i < 5; i++) {
markers.push(createRandomMarker(i, $scope.map.bounds))
}
for (var y = 0; y < 5; y++) {
var marker = markers[y];
marker.onClicked = function() {
marker.showWindow = true;
}
}
$scope.randomMarkers = markers;
}
}, true);
已解决这是通过使用nitewulf50链接的子弹来解决的。
一些注意事项:
似乎Window标记只能有一个孩子。所以我需要将所有内容包含在div中。
Windows和Window似乎像您想要的那样很难工作。几天前我在Windows上遇到了问题,并由cthrax在github上发布了使用Window的解决方案:
https://github.com/angular-ui/angular-google-maps/issues/633
希望对您有帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句