1
我在格式生成XML:如何在Google Map HTML infoWindow中放置外部URL超鏈接?
<marker lat="41.932797" lng="21.483765" url="https://myhostname.com/webtop/AELView/?textdirection=LTR&guiorientation=LTR&filtername=Example_Unassigned&filtertype=system" severity="0" />
<marker lat="41.532797" lng="21.183767" url="https://myhostname.com/webtop/AELView/?textdirection=LTR&guiorientation=LTR&filtername=Example_Unassigned&filtertype=device" severity="1" />
我希望把外部URL地址在信息窗口上的標記,當我點擊它。 但是,如果我把它放在XML中,我的地圖不會顯示任何標記。 如果我將示例中的這個URL地址剪切爲https://myhostname.com/webtop/AELView infoWindow會顯示此信息,但是顯示爲普通文本而非URL。 如何啓用所以當點擊標記我可以點擊並轉到外部URL地址? 我唯一的HTML文件是:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Google Maps</title>
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&" type="text/javascript"></script>
</head>
<body onunload="GUnload()">
<table border=1>
<tr>
<td>
<div id="map" style="width: 1550px; height: 1450px"></div>
</td>
</tr>
</table>
<script type="text/javascript">
//<![CDATA[
if (GBrowserIsCompatible()) {
var gmarkers = [];
function createMarker(point,name,alarm) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
// **this is where I wan to call URL**
marker.openInfoWindowHtml(alarm);
});
return marker;
}
function myclick(i) {
GEvent.trigger(gmarkers[i], "click");
}
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(41.932797,21.483765), 10);
GDownloadUrl("alarms.xml", function(doc) {
var xmlDoc = GXml.parse(doc);
var markers = xmlDoc.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
// obtain the attribues of each marker
var lat = parseFloat(markers[i].getAttribute("lat"));
var lng = parseFloat(markers[i].getAttribute("lng"));
var point = new GLatLng(lat,lng);
var alarm = markers[i].getAttribute("alarm");
var label = markers[i].getAttribute("label");
// create the marker
var marker = createMarker(point,label,alarm);
map.addOverlay(marker);
}
});
}
//]]>
</script>
</body>
</html>