0
我的Google Map突然停止工作,儘管我沒有對代碼進行任何更改,我無法解決原因。谷歌地圖不再出現
我使用的是map.js:
var geocoder;
var map;
var marker;
var layers = [];
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng (50.31697, -3.670807);
var myOptions = {
zoom: 10,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map-container"),
myOptions);
marker = new google.maps.Marker({map:map});
layers[100] = new google.maps.KmlLayer('http://www.southdevonaonb.org.uk/cordialemapping/kmzdata/100.kml', {preserveViewport: true});
layers[200] = new google.maps.KmlLayer('http://www.southdevonaonb.org.uk/cordialemapping/kmzdata/200.kml', {preserveViewport: true});
layers[300] = new google.maps.KmlLayer('http://www.southdevonaonb.org.uk/cordialemapping/kmzdata/boundaryline.kml', {preserveViewport: true});
layers[0] = new google.maps.KmlLayer('http://www.southdevonaonb.org.uk/cordialemapping/kmzdata/beta0.kml', {preserveViewport: true});
layers[1] = new google.maps.KmlLayer('http://www.southdevonaonb.org.uk/cordialemapping/kmzdata/beta1.kml', {preserveViewport: true});
layers[2] = new google.maps.KmlLayer('http://www.southdevonaonb.org.uk/cordialemapping/kmzdata/beta2.kml', {preserveViewport: true});
layers[10] = new google.maps.KmlLayer('http://www.southdevonaonb.org.uk/cordialemapping/kmzdata/beta10.kml', {preserveViewport: true});
layers[11] = new google.maps.KmlLayer('http://www.southdevonaonb.org.uk/cordialemapping/kmzdata/beta11.kml', {preserveViewport: true});
layers[18] = new google.maps.KmlLayer('http://www.southdevonaonb.org.uk/cordialemapping/kmzdata/alpha18.kml', {preserveViewport: true});
layers[19] = new google.maps.KmlLayer'http://www.southdevonaonb.org.uk/cordialemapping/kmzdata/withtiledoverlays/19/doc.kml', {preserveViewport: true});
layers[20] = new google.maps.KmlLayer'http://www.southdevonaonb.org.uk/cordialemapping/kmzdata/withtiledoverlays/20/doc.kml', {preserveViewport: true});
layers[21] = new google.maps.KmlLayer'http://www.southdevonaonb.org.uk/cordialemapping/kmzdata/withtiledoverlays/21/doc.kml', {preserveViewport: true});
layers[22] = new google.maps.KmlLayer'http://www.southdevonaonb.org.uk/cordialemapping/kmzdata/withtiledoverlays/22/doc.kml', {preserveViewport: true});
layers[23] = new google.maps.KmlLayer('http://www.southdevonaonb.org.uk/cordialemapping/kmzdata/withtiledoverlays/23/doc.kml', {preserveViewport: true});
layers[24] = new google.maps.KmlLayer('http://www.southdevonaonb.org.uk/cordialemapping/kmzdata/withtiledoverlays/24/doc.kml', {preserveViewport: true});
layers[25] = new google.maps.KmlLayer('http://www.southdevonaonb.org.uk/cordialemapping/kmzdata/withtiledoverlays/25/doc.kml', {preserveViewport: true});
layers[26] = new google.maps.KmlLayer('http://www.southdevonaonb.org.uk/cordialemapping/kmzdata/withtiledoverlays/26/doc.kml', {preserveViewport: true});
layers[46] = new google.maps.KmlLayer('http://www.southdevonaonb.org.uk/cordialemapping/kmzdata/holbeton.kml', {preserveViewport: true});
for (var i = 1; i < layers.length; i++) {
}
}
function codeAddress() {
var address = document.getElementById ("address").value;
geocoder.geocode ({ 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results [1].geometry.location);
marker.setPosition(results [1].geometry.location);
map.setZoom(14);
}
else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
function toggleLayer(i) {
if(layers[i].getMap() === null) {
layers[i].setMap(map);
}
else {
layers[i].setMap(null);
}
}
google.maps.event.addDomListener(window, 'load', initialize);
我能想到的是,如果在地圖容器的尺寸並沒有規定,但這些都不會被更改之前,做工精細的唯一的事。
謝謝!一個簡單的解決方案...雖然我不知道如何改變! – Riverbum75 2013-05-06 00:46:55