當我點擊地圖頁面上的鏈接(不是自己標記它)時,我需要打開地圖上的信息窗口。這是到目前爲止我的代碼,在google maps中通過marker id獲取marker customInfo
var marker = new MarkerWithLabel({
map: resultsMap,
id: label,
position: latlng,
title: "Address",
// radius: int_radius ,
draggable: false,
labelAnchor: new google.maps.Point(10, 35),
labelContent: label,
labelClass: "labels",
labelInBackground: false,
mapTypeId: google.maps.MapTypeId.ROADMAP,
icon: image,
customInfo: "dynamic data for each marker"
});
,並調用函數
function bindInfoWindow(resultsMap, marker, infoWindow) {
google.maps.event.addListener(marker, 'click',
function(){
infoWindow.setContent(marker.customInfo);
infoWindow.open(resultsMap,marker);
});
$(document).on('click','.store-title', function(){
var linkId = $(this).attr('id');
infoWindow.setContent(marker.customInfo);
infoWindow.open(resultsMap,marker);
});
}
在我的情況,我不能用一個數組來存儲標記。有沒有辦法通過使用下面的條件獲得marker.customInfo?請注意當我點擊標記它的作品。我需要它用於後者的onclick功能。
infoWindow.setContent(marker.customInfo where marker.id==linkId);
請有人可以幫我 – cmit