当我点击地图页面上的链接(不是自己标记它)时,我需要打开地图上的信息窗口。这是到目前为止我的代码,在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