源代码中有一个添加Maker功能
我怎样才能访问它?
另外,如何更改图标并将infoBox添加到标记?
this.addMarker = function (lat, lng, icon, infoWindowContent, label, url, thumbnail)
答案 0 :(得分:0)
Javascript是一种灵活的语言。您可以将代码编写为:
var marker = new google.maps.Marker({ position: latLng, clickable: true, icon: markerJSON[i].icon, myExtraEntity1: markerJSON[i].oldLatLng, myExtraEntity2: markerJSON[i].headshipID});
marker.myExtraEntity3 = markerJSON[i].id;
marker.map=mymap;
var content= "Tool: " + markerJSON[i].toolName+ " <br><br>Gang: " + markerJSON[i].gangName + "<br><br>Gang Cheff: " +
markerJSON[i].cheff+ "<br><br><a href='javascript:drawPath(" + marker.id + ")'>[1 Day Path]</a><a href='javascript:cleanPath(" + marker.id + ")'>[Clean Path]</a>"
var boxText = document.createElement("div");
boxText.className = "infoBox";
boxText.innerHTML = content;
marker.info = new google.maps.InfoWindow({
content: boxText
});
addInfoWindow(marker, marker.info.content);
markers.push(marker);