1
在這個項目中,我有兩種不同的標記,我使用下面的代碼在地圖上顯示。infowindow隱藏在懸停標記
for (i = 0; i < beaches.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(beaches[i][1], beaches[i][2]),
map: mapSingle,
icon: icons[beaches[i][3]].icon
});
var infowindow = new google.maps.InfoWindow();
var content = beaches[i][0];
google.maps.event.addListener(marker,'mouseover', (function(marker,content,infowindow){
return function() {
infowindow.setContent(content);
infowindow.open(mapSingle,this);
};
})(marker,content,infowindow));
markers.push(marker);
}
現在有了新的要求,我必須放置一種可拖動的新型標記。所以,當我做懸停在此拖動的標記我有這樣的代碼
com_current = new google.maps.Marker({
map: mapSingle,
draggable: true,
icon: com_Image,
animation: google.maps.Animation.DROP,
position: {lat: parseFloat('20.5937'), lng: parseFloat('78.9629')},
});
google.maps.event.addListener(com_current, 'mouseover', function() {
var info = infowindow.getContent();
infowindow.setContent('show the position of the marker');
infowindow.open(mapSingle, this);
});
現在,我得到的問題是,它的信息窗口變得開放這是確定其他已經打開信息窗口皮的,但一些,反之亦然。我怎樣才能讓其他已經打開的標記顯示,即使我懸停在這個可拖動的標記。
謝謝@Naveen。如果我將鼠標懸停在一個標記上,我如何隱藏其他打開的infowindow。你能幫忙嗎 – sanin
只需使用一個信息窗口對象。那麼地圖上只會有一個信息窗口。 –
這就是我在我的問題中所做的。但是,它不工作 – sanin