如何在谷歌地图信息窗口中实现用户最喜欢的选项。例如。我想要与http://hotpads.com/rentals/24276-Finely-Drive-Moreno-Valley-CA-92553--2w2hh5wwds7ce#lat=33.913198677411614&lon=-117.2406005859375&zoom=18&previewId=1x0ecwmx9ayrr=true&dupe=Groupingheat&con building&listingTypes=rental,sublet,room,corporate&includeVaguePricing=false&loan=30,0.04,0&resultsPerQuad=24 ,但不知道该怎么做。请给我一个实现最喜欢的选项的解决方案。
问问题
257 次
1 回答
0
我不明白您是否想要 infowindow html 的代码或管理收藏夹的算法...无论如何这是代码...但您必须修改它可能是如果您正在迭代一组标记...希望这对您有所帮助。 ..
var favourites = [];
var contentString = '<div id="content">'+
'<ul id="myLinks">'+
'<li><a href="javascript:" id="markerID" onclick="addRemoveFavourite(this);">add to favourites</a></li>'
'</ul>'+
'</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString,
maxWidth: 200
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
function addRemoveFavourite(link){
if(link.innerHTML == "add to favourites"){
link.innerHTML = "remove from favourites";
favourites.push(link.id);
} else {
link.innerHTML = "add to favourites";
var index = favourites.indexOf(link.id);
favourites.splice(index,1);
}
}
于 2013-06-19T06:04:13.737 回答