我整天都在使用 Google Maps API。我可以拉入所有标记并将自定义图标放在大约 50 点上。但是,我无法为标记滴设置间隔。我究竟做错了什么?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Golf</title>
<script src="http://maps.google.com/maps/api/js?sensor=false"
type="text/javascript"></script>
<style type="text/css">
.mapInfo {
font-size:12px;
text-transform:capitalize;
}
</style>
<script type="text/javascript">
//<![CDATA[
function load() {
var map = new google.maps.Map(document.getElementById("map"), {
center: new google.maps.LatLng(41.449799, -86.241248),
zoom: 9,
mapTypeId: 'roadmap'
});
var infoWindow = new google.maps.InfoWindow;
// Change this depending on the name of your PHP file
downloadUrl("golf-xml.php", function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
//var name = markers[i].getAttribute("name");
var address = markers[i].getAttribute("address");
var type = markers[i].getAttribute("value");
var value = markers[i].getAttribute("value");
var town = markers[i].getAttribute("town");
//var erase = markers[i].getAttribute("erase");
var point = new google.maps.LatLng(
parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
//var html = "<span class='mapInfo'><b>Address:</b> " + address + ", " + town + "<br/><b>Price:</b> " + value + "</span>";
var html = "<span class='mapInfo'><b>Price:</b> " + value + "<br/><b>Address:</b> " + address + ", " + town + "</span>";
var icon = customIcons[type] || {};
//alert (point);
var marker = new google.maps.Marker({
map: map,
position: point,
icon: '1364428325_golf.png',
animation: google.maps.Animation.DROP,
shadow: icon.shadow
});
bindInfoWindow(marker, map, infoWindow, html);
}
});
}
function drop() {
for (var i =0; i < point.length; i++) {
setTimeout(function() {
marker();
}, i * 200);
}
}
function bindInfoWindow(marker, map, infoWindow, html) {
google.maps.event.addListener(marker, 'click', function() {
infoWindow.setContent(html);
infoWindow.open(map, marker);
});
}
function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;
request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};
request.open('GET', url, true);
request.send(null);
}
function doNothing() {}
//]]>
</script>
</head>
<body onLoad="load()" style="margin: 0; padding: 0;" >
<div class="land"><span class="land">Copy</span>
<br />
</div>
<div id="map" style="width: 100%; height: 620px"></div>
</body>
</html>