我在這個頁面上有一些奇怪的問題:http://www.bluprintliving.com/locations似乎我想要顯示的標記顯示在Firefox中但未顯示Chrome/Safari或IE。我不確定從哪裏開始調試此問題,因爲沒有javascript錯誤。爲什麼谷歌地圖標記不在Chrome,Safari和Internet Explorer上顯示Firefox
該代碼分爲兩部分。第一個js文件http://www.bluprintliving.com/js/local-area-gmaps.js
var localSearch = new GlocalSearch();
var global_point;
var icon = new GIcon();
icon.image = "http://www.google.com/mapfiles/marker.png";
icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
icon.iconSize = new GSize(20, 34);
icon.shadowSize = new GSize(37, 34);
icon.iconAnchor = new GPoint(10, 34);
function usePointFromPostcode(postcode, callbackFunction) {
localSearch.setSearchCompleteCallback(null,
function() {
if (localSearch.results[0])
{
var resultLat = localSearch.results[0].lat;
var resultLng = localSearch.results[0].lng;
var point = new GLatLng(resultLat,resultLng);
callbackFunction(point);
global_point = point;
}else{
alert("Postcode not found!");
}
});
localSearch.execute(postcode + ", UK");
}
function setCenterToPointLondon(point) {
//map.setCenter(point, 15);
map.setCenter(new GLatLng(51.50788772102843,-0.1050567626953125), 11);
var marker = new GMarker(point,icon);
map.addOverlay(marker);
}
function setCenterToPoint(point) {
map.setCenter(point, 15);
var marker = new GMarker(point,icon);
map.addOverlay(marker);
}
function createMarker(point,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
然後在頁面上的每個地圖有是它的一個部分,它看起來像:
第一張地圖
<div id="map" class="location-map"></div>
<script type="text/javascript">
//<![CDATA[
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(51.50788772102843,-0.1050567626953125), 11);
usePointFromPostcode("WC1N 2PL", setCenterToPointLondon);
usePointFromPostcode("EC1M 5RR", setCenterToPointLondon);
//]]>
</script>
第二張地圖
<div id="map-no-5-doughty-street" class="location-map"></div>
<script type="text/javascript">
//<![CDATA[
var map = new GMap2(document.getElementById("map-no-5-doughty-street"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(51.50788772102843,-0.1050567626953125), 11);
usePointFromPostcode("WC1N2PL", setCenterToPoint);
//]]>
</script>
第三張地圖*
<div id="map-turnmill-street" class="location-map"></div>
<script type="text/javascript">
//<![CDATA[
var map = new GMap2(document.getElementById("map-turnmill-street"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(51.50788772102843,-0.1050567626953125), 11);
usePointFromPostcode("EC1M5RR", setCenterToPoint);
//]]>
</script>
現在,這些都是動態生成這樣一個頁面有可能增長到地圖的位置生長。
這一切都按照預期在Firefox中運行,但不是其他瀏覽器。標記不顯示,並且看起來中心也在其他瀏覽器中關閉。
幫助!請! :)
在此先感謝
UPDATE
我已經把所有的代碼在一個頁面上,所以很容易看出問題和調試:http://www.bluprintliving.com/google-maps.php
再次感謝