我有一张使用Google Maps for AngularJS的 Map ,它有两个标记,每个标记显示一个带有数据的infoWindow .
我第一次点击标记时,一切正常 . 如果我单击第二个标记,仍然可以正常工作 . 但是当我再次单击第一个标记时,infoWindow不会改变它的位置:与第一个标记关联的数据显示在第二个标记上的infoWindow上,而不是第一个标记上 .
什么可能导致这个问题?
我的HTML代码:
<ui-gmap-google-map center='map.center' zoom='map.zoom' options='map.options' control='map.control'>
<ui-gmap-markers models="places" coords="'coords'" idKey="'idKey'" isLabel="true" options="'options'" events='map.markerEvents'></ui-gmap-markers>
<ui-gmap-window coords="mapOptions.markers.selected.coords" show="windowOptions.show" options="windowOptions" closeClick="closeClick()" ng-cloak>
//SOME CODE HERE
</ui-gmap-window>
</ui-gmap-google-map>
与标记关联的click事件:
$scope.map = { center: { latitude: 43, longitude: -8.3 }, zoom: 8, control: {}, markerEvents: {
click: function(marker){
if(marker.model.title != USER_LOCATION){
$scope.onClick(marker.model);
$scope.mapOptions.markers.selected = marker.model;
}
}
}, options: $scope.mapOptions};
windowOptions的内容:
$scope.windowOptions = {
show: false,
boxClass: "infobox",
boxStyle: {
backgroundColor: "transparent",
border: "1px solid #C7CECE",
borderRadius: "5px",
width: "85%"
},
disableAutoPan: false,
maxWidth: 0,
infoBoxClearance: new google.maps.Size(1, 1),
pixelOffset: new google.maps.Size(-175, -250),
zIndex: null,
/*closeBoxMargin: "10px",
closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif",*/
isHidden: false,
pane: "floatPane",
enableEventPropagation: false
};
如果我使用“x”按钮关闭标记,则不会再出现此问题 . 但我不希望用户需要手动关闭infoWindow .
任何帮助,将不胜感激!谢谢
编辑:我包含我的mapOptions代码:
$scope.mapOptions = {
minZoom: 3,
zoomControl: false,
draggable: true,
navigationControl: false,
mapTypeControl: false,
scaleControl: false,
streetViewControl: false,
disableDoubleClickZoom: false,
keyboardShortcuts: true,
markers: {
selected: {}
}
};
1 回答
我无法重现您遇到的问题,但以下示例演示了如何在标记点击上显示信息窗口: