以下在IE和Chrome上運行正常,但不在Firefox上運行(uptodate,27.0.1)。Google地圖標記不會在Firefox上生成Infowindow
我看到的症狀是,點擊標記有時會正確顯示infowindow,有時它不會 - 當它沒有時,我會看到一個白色的向下三角形,顯示地圖左上角的街景圖標和一個「X 「窗戶關閉在右邊的同一層。
協助調試,感激不盡。
我的簡化的代碼如下所示(它仍然顯示錯誤):
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Map Test</title>
<script src="http://maps.google.com/maps/api/js?sensor=false"
type="text/javascript"></script>
</head>
<body>
<center>
<div id="map" style="width: 1024px; height: 800px;"></div>
</center>
<script type="text/javascript">
xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","MapTestData.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
var speakers=xmlDoc.getElementsByTagName("SPEAKER");
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: new google.maps.LatLng(52.4050, -2),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker, i, address, desc, j, iconurl;
var markerBounds = new google.maps.LatLngBounds();
for (i = 0; i < speakers.length; i++) {
marker = new google.maps.Marker({
map: map,
title: speakers[i].getElementsByTagName("NAME")[0].childNodes[0].nodeValue,
position: new google.maps.LatLng(speakers[i].getElementsByTagName("LAT")[0].childNodes[0].nodeValue, speakers[i].getElementsByTagName("LONG")[0].childNodes[0].nodeValue)
});
marker.open = false;
speakers[i].desc = '<p style="text-align:left"><b>';
if (speakers[i].getElementsByTagName("EMAIL")[0].childNodes.length > 0) {
speakers[i].desc += 'Email: <a href="mailto:'+speakers[i].getElementsByTagName("EMAIL")[0].childNodes[0].nodeValue+'">'+speakers[i].getElementsByTagName("NAME")[0].childNodes[0].nodeValue+'</a></b>';
}
else {
speakers[i].desc +=speakers[i].getElementsByTagName("NAME")[0].childNodes[0].nodeValue+'</b>';
};
if (speakers[i].getElementsByTagName("TEL")[0].childNodes.length > 0) {
speakers[i].desc += ' <b>Tel:</b> '+speakers[i].getElementsByTagName("TEL")[0].childNodes[0].nodeValue;
};
for (j=0; j < speakers[i].getElementsByTagName("DISPLAY").length; j++) {
speakers[i].desc += '<br> ' + speakers[i].getElementsByTagName("DISPLAY")[j].childNodes[0].nodeValue;
};
markerBounds.extend(new google.maps.LatLng(speakers[i].getElementsByTagName("LAT")[0].childNodes[0].nodeValue, speakers[i].getElementsByTagName("LONG")[0].childNodes[0].nodeValue));
map.fitBounds(markerBounds);
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
if (!marker.open) {
infowindow.setContent(speakers[i].desc);
infowindow.open(map, marker);
marker.open = true;
}
else {
infowindow.close();
marker.open = false;
}
}
})(marker, i));
};
</script>
</body>
</html
代碼工作關閉下列(測試)數據:
<MPF>
<SPEAKERS>
<SPEAKER>
<NAME>Person A</NAME>
<PLACE>Ryton</PLACE>
<LAT>52.36563</LAT>
<LONG>-1.433982</LONG>
<TEL></TEL>
<EMAIL></EMAIL>
<CAR></CAR>
<MEAL>No</MEAL>
<PETROL>No</PETROL>
<AREA>40 miles</AREA>
<DISTANCE>40</DISTANCE>
<EVENINGS>None</EVENINGS>
<DISPLAYS>
<DISPLAY>Display 1a</DISPLAY>
<DISPLAY>Display 1b</DISPLAY>
<DISPLAY>Display 1c</DISPLAY>
</DISPLAYS>
</SPEAKER>
<SPEAKER>
<NAME>Person B</NAME>
<PLACE>Nottingham</PLACE>
<LAT>52.976153</LAT>
<LONG>-1.141237</LONG>
<TEL></TEL>
<EMAIL></EMAIL>
<CAR></CAR>
<MEAL>Coffee</MEAL>
<PETROL>No</PETROL>
<AREA>30-40 miles</AREA>
<DISTANCE>30</DISTANCE>
<EVENINGS>By arrangement</EVENINGS>
<DISPLAYS>
<DISPLAY>Display 2a</DISPLAY>
<DISPLAY>Display 2b</DISPLAY>
<DISPLAY>Display 2c</DISPLAY>
</DISPLAYS>
</SPEAKER>
<SPEAKER>
<NAME>Person C</NAME>
<PLACE>Solihull</PLACE>
<LAT>52.411811</LAT>
<LONG>-1.77761</LONG>
<TEL></TEL>
<EMAIL></EMAIL>
<CAR></CAR>
<MEAL>By arrangement</MEAL>
<PETROL>By arrangement</PETROL>
<AREA></AREA>
<DISTANCE></DISTANCE>
<EVENINGS></EVENINGS>
<DISPLAYS>
<DISPLAY>Display 3a</DISPLAY>
<DISPLAY>Display 3b</DISPLAY>
<DISPLAY>Display 3c</DISPLAY>
</DISPLAYS>
</SPEAKER>
<SPEAKER>
<NAME>Person D</NAME>
<PLACE>Sutton Coldfield</PLACE>
<LAT>52.570299</LAT>
<LONG>-1.82407</LONG>
<TEL></TEL>
<EMAIL></EMAIL>
<CAR></CAR>
<MEAL>By arrangement</MEAL>
<PETROL>By arrangement</PETROL>
<AREA></AREA>
<DISTANCE></DISTANCE>
<EVENINGS></EVENINGS>
<DISPLAYS>
<DISPLAY>Display 4a</DISPLAY>
<DISPLAY>Display 4b</DISPLAY>
</DISPLAYS>
</SPEAKER>
<SPEAKER>
<NAME>Person E</NAME>
<PLACE>Sutton Coldfield</PLACE>
<LAT>52.573</LAT>
<LONG>-1.81</LONG>
<TEL></TEL>
<EMAIL></EMAIL>
<CAR></CAR>
<MEAL>By arrangement</MEAL>
<PETROL>By arrangement</PETROL>
<AREA>30 miles</AREA>
<DISTANCE>30</DISTANCE>
<EVENINGS></EVENINGS>
<DISPLAYS>
<DISPLAY>Display 5a</DISPLAY>
<DISPLAY>Display 5b</DISPLAY>
</DISPLAYS>
</SPEAKER>
<SPEAKER>
<NAME>Person F</NAME>
<PLACE>Hereford</PLACE>
<LAT>52.0598132</LAT>
<LONG>-2.682874</LONG>
<TEL></TEL>
<EMAIL></EMAIL>
<CAR>Yes</CAR>
<MEAL>By arrangement</MEAL>
<PETROL>By arrangement</PETROL>
<AREA>By arrangement</AREA>
<DISTANCE></DISTANCE>
<EVENINGS>None</EVENINGS>
<DISPLAYS>
<DISPLAY>Display 6a</DISPLAY>
<DISPLAY>Display 6b</DISPLAY>
<DISPLAY>Display 6c</DISPLAY>
</DISPLAYS>
</SPEAKER>
<SPEAKER>
<NAME>Person G</NAME>
<PLACE>Malvern</PLACE>
<LAT>52.106032</LAT>
<LONG>-2.318292</LONG>
<TEL></TEL>
<EMAIL></EMAIL>
<CAR></CAR>
<MEAL>No</MEAL>
<PETROL>Half cost</PETROL>
<AREA>None</AREA>
<DISTANCE></DISTANCE>
<EVENINGS>None</EVENINGS>
<DISPLAYS>
<DISPLAY>Display 7a</DISPLAY>
<DISPLAY>Display 7b</DISPLAY>
<DISPLAY>Display 7c</DISPLAY>
</DISPLAYS>
</SPEAKER>
<SPEAKER>
<NAME>Person H</NAME>
<PLACE>Sutton Coldfield</PLACE>
<LAT>52.565104</LAT>
<LONG>-1.803349</LONG>
<TEL></TEL>
<EMAIL></EMAIL>
<CAR></CAR>
<MEAL>By arrangement</MEAL>
<PETROL>By arrangement</PETROL>
<AREA>By arrangement</AREA>
<DISTANCE></DISTANCE>
<EVENINGS>Daytime available</EVENINGS>
<DISPLAYS>
<DISPLAY>Display 8a</DISPLAY>
<DISPLAY>Display 8b</DISPLAY>
<DISPLAY>Display 8c</DISPLAY>
<DISPLAY>Display 8d</DISPLAY>
<DISPLAY>Display 8e</DISPLAY>
<DISPLAY>Display 8f</DISPLAY>
</DISPLAYS>
</SPEAKER>
<SPEAKER>
<NAME>Person I</NAME>
<PLACE>Banbury</PLACE>
<LAT>52.052179</LAT>
<LONG>-1.352288</LONG>
<TEL></TEL>
<EMAIL></EMAIL>
<CAR>By arrangement</CAR>
<MEAL>By arrangement</MEAL>
<PETROL>By arrangement</PETROL>
<AREA>By arrangement</AREA>
<DISTANCE></DISTANCE>
<EVENINGS>By arrangement</EVENINGS>
<DISPLAYS>
<DISPLAY>Display 9a</DISPLAY>
<DISPLAY>Display 9b</DISPLAY>
<DISPLAY>Display 9c</DISPLAY>
</DISPLAYS>
</SPEAKER>
<SPEAKER>
<NAME>Person J</NAME>
<PLACE>Upton Snodsbury</PLACE>
<LAT>52.18615</LAT>
<LONG>-2.085697</LONG>
<TEL></TEL>
<EMAIL></EMAIL>
<CAR></CAR>
<MEAL>By arrangement</MEAL>
<PETROL>By arrangement</PETROL>
<AREA></AREA>
<DISTANCE></DISTANCE>
<EVENINGS></EVENINGS>
<DISPLAYS>
<DISPLAY>Display 10a</DISPLAY>
<DISPLAY>Display 10b</DISPLAY>
<DISPLAY>Display 10c</DISPLAY>
</DISPLAYS>
</SPEAKER>
<SPEAKER>
<NAME>Person K</NAME>
<PLACE>Tollerton</PLACE>
<LAT>52.899822</LAT>
<LONG>-1.097537</LONG>
<TEL></TEL>
<EMAIL></EMAIL>
<CAR></CAR>
<MEAL>By arrangement</MEAL>
<PETROL>By arrangement</PETROL>
<AREA></AREA>
<DISTANCE></DISTANCE>
<EVENINGS></EVENINGS>
<DISPLAYS>
<DISPLAY>Display 11a</DISPLAY>
</DISPLAYS>
</SPEAKER>
<SPEAKER>
<NAME>Person L</NAME>
<PLACE>Burton ?</PLACE>
<LAT>52.814028</LAT>
<LONG>-1.637136</LONG>
<TEL></TEL>
<EMAIL></EMAIL>
<CAR></CAR>
<MEAL>By arrangement</MEAL>
<PETROL>By arrangement</PETROL>
<AREA></AREA>
<DISTANCE></DISTANCE>
<EVENINGS></EVENINGS>
<DISPLAYS>
<DISPLAY>Display 12a</DISPLAY>
<DISPLAY>Display 12b</DISPLAY>
<DISPLAY>Display 12c</DISPLAY>
<DISPLAY>Display 12d</DISPLAY>
<DISPLAY>Display 12e</DISPLAY>
<DISPLAY>Display 12f</DISPLAY>
</DISPLAYS>
</SPEAKER>
<SPEAKER>
<NAME>Person M</NAME>
<PLACE>Coventry</PLACE>
<LAT>52.391121</LAT>
<LONG>-1.498386</LONG>
<TEL></TEL>
<EMAIL></EMAIL>
<CAR></CAR>
<MEAL></MEAL>
<PETROL>By arrangement</PETROL>
<AREA>By arrangement</AREA>
<DISTANCE></DISTANCE>
<EVENINGS></EVENINGS>
<DISPLAYS>
<DISPLAY>Display 13a</DISPLAY>
<DISPLAY>Display 13b</DISPLAY>
<DISPLAY>Display 13c</DISPLAY>
</DISPLAYS>
</SPEAKER>
<SPEAKER>
<NAME>Person N</NAME>
<PLACE>Birmingham</PLACE>
<LAT>52.404588</LAT>
<LONG>-1.930753</LONG>
<TEL></TEL>
<EMAIL></EMAIL>
<CAR></CAR>
<MEAL>By arrangement</MEAL>
<PETROL></PETROL>
<AREA></AREA>
<DISTANCE></DISTANCE>
<EVENINGS></EVENINGS>
<DISPLAYS>
<DISPLAY>Display 14a</DISPLAY>
<DISPLAY>Display 14b</DISPLAY>
</DISPLAYS>
</SPEAKER>
</SPEAKERS>
</MPF>
'xmlDoc = xmlhttp.responseXML;'xmlDoc是'null'之後。它需要一些時間來讀取數據。 –
如果將xmlDoc = xmlhttp.responseXML行更改爲xmlDoc = xmlhttp.responseText; –
@AntoJurković:這是一個同步請求 –