2
您好我有一個網站使用Google Maps API v3作爲會員地點。在Google地圖上的Google Maps API v3問題
但與Internet Explorer我有幾個問題:
1.-當網站加載它拋出一個errror(僅限於IE)的JavaScript:_
Message: Invalid property value.
Line: 33
Char: 212
Code: 0
URI: http://maps.gstatic.com/cat_js/intl/en_gb/mapfiles/api-3/4/7/%7Bmain,geometry%7D.js
這是在JS我裝: http://maps.google.com/maps/api/js?libraries=geometry &傳感器=真
這是該文件的最後部分(即導致問題的部分):
[...]
var loadScriptTime = (new Date).getTime();
getScript("http://maps.gstatic.com/cat_js/intl/en_gb/mapfiles/api-3/4/7/%7Bmain,geometry%7D.js");
})();
2:地圖載入和顯示正確的位置,但它並不顯示任何控制和無法與之互動地圖(這可能是因爲第一個錯誤)
有沒有人知道如何解決這個問題?
謝謝!
EDIT --------------------------
下面是我用來加載地圖的功能:
function initialize() {
london = new google.maps.LatLng(51.5, 0);
uk = new google.maps.LatLng(55.7, -4);
var myOptions = {
backgroundColor: '#FFFFF',
zoom: 12,
navigationControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map_canvas = document.getElementById("map_canvas");
map = new google.maps.Map(map_canvas, myOptions);
google.maps.event.addListener(map, 'mouseover', function(event) {
$(map_canvas).ancestors()[0].addClassName("bigGMap");
});
google.maps.event.addListener(map, 'mouseout', function(event) {
$(map_canvas).ancestors()[0].removeClassName("bigGMap");
});
google.maps.event.addListenerOnce(map, 'click', function(event) {
placeMarker(event.latLng);
});
getMyLocation();
}
function getMyLocation()
{
// Try W3C Geolocation (Preferred)
if(navigator.geolocation) {
browserSupportFlag = true;
navigator.geolocation.getCurrentPosition(function(position) {
initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
map.setCenter(initialLocation);
}, function() {
handleNoGeolocation(browserSupportFlag);
});
// Try Google Gears Geolocation
} else if (google.gears) {
browserSupportFlag = true;
var geo = google.gears.factory.create('beta.geolocation');
geo.getCurrentPosition(function(position) {
initialLocation = new google.maps.LatLng(position.latitude,position.longitude);
map.setCenter(initialLocation);
}, function() {
handleNoGeoLocation(browserSupportFlag);
});
// Browser doesn't support Geolocation
} else
{
browserSupportFlag = false;
handleNoGeolocation(browserSupportFlag);
}
}
function handleNoGeolocation(errorFlag) {
map.setZoom(6),
map.setCenter(uk);
map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
}
function loadMapScript() {
var map_api = document.createElement("script");
var gears = document.createElement("script");
map_api.type = "text/javascript";
map_api.src = "http://maps.google.com/maps/api/js?libraries=geometry&sensor=true&callback=initialize";
gears.type = "text/javascript";
gears.src = "http://code.google.com/apis/gears/gears_init.js";
document.body.appendChild(map_api);
document.body.appendChild(gears);
}
即使錯誤顯示在谷歌代碼中,當初始化地圖時,問題很可能出現在您的頁面中。你也可以顯示該代碼嗎? – 2011-03-29 12:59:30
@Pekka我剛剛添加了我用來加載地圖的功能。 – SERPRO 2011-03-29 13:08:49
你使用原型作爲你的JS框架嗎? – kjy112 2011-03-29 13:23:04