0
嘿大家, 我需要做一個谷歌地圖與我們的客戶的標記 但是,我不善於編程仍然在學校,並沒有真正得到很多節目:( 然而我的問題是,我能夠在地圖上得到幾個標記,但不是所有的標記都會顯示。我工作的地址不是經緯度。我的谷歌地圖不會顯示每一個標記
這裏是我的腳本
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjU0EJWnWPMv7oQ-jjS7dYxTPZYElJSBeBUeMSX5xXgq6lLjHthSAk20WnZ_iuuzhMt60X_ukms-AUg"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
//load Google Map
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
var geocoder = new GClientGeocoder();
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
//create randomnumber to prevent caching and retrieve xml file
//data.xml vervangen door weg naar .xml bestand
GDownloadUrl("data.xml", function(data, responseCode) {
var xml = GXml.parse(data);
//store markers in markers array
var markers = xml.documentElement.getElementsByTagName("marker");
//while loop ipv for loop
var i = 0
do
{
var address = markers[i].getAttribute("address");
var html = markers[i].getAttribute("html");
showAddress(map,geocoder,address,html);
timer();
}
while (i <= 18);
function timer()
{
i++
setTimeout("timer()",1000);
}
//Create marker and set up event window
function createMarker(point,html){
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
//showAddress
function showAddress(map,geocoder,address,html) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + " niet gevonden");
} else {
map.setCenter(point, 12);
var marker = createMarker(point,html+'<br/><br/>'+address);
map.addOverlay(marker);
}
}
);
}
}
); //close GDownloadUrl
} //close GBrowserIsCompatible
} //close load
//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 1000px; height: 700px"></div>
</body>
</html>
THX這個工程:d 非常感謝大家一直忙於這對於過去的3天現在:P – ronnie
沒問題。花了我很長時間才弄清楚我第一次遇到它! – quis
有沒有辦法加快速度?因爲我需要在那裏得到6k標記,並且像這樣,最快的可能是大約20分鐘xD – ronnie