0

I made a google map app use google map api v3 and kml file. However, sometime it work, and sometime it always zoom to the max level and center is not mine options.center(near Africa).

Why is it?

And my kml file was uploaded to mine Google Map account.

function initialize1() {
var myLatlng = new google.maps.LatLng(30.566991,114.315491);
var myOptions = {
zoom: 10,
center: myLatlng,
overviewMapControl:true,
overviewMapControlOptions: {
 opened:true  
},
scaleControl:true,
mapTypeId: google.maps.MapTypeId.ROADMAP
}

map1= new google.maps.Map(document.getElementById("map_canvas1"), myOptions);


var nyLayer = new google.maps.KmlLayer('https://maps.google.com/maps/ms? **************',
{suppressInfoWindows: true});
nyLayer.setMap(map1);
google.maps.event.addListener(nyLayer, 'click', function(kmlEvent) {
var text = kmlEvent.featureData.description;
showInDiv(text);
});
}

Thanks very much,

4

1 回答 1

0

当 kml 文件不存在/找不到时,就会发生这种行为。您尚未提供文件的 URL 以允许对其进行测试。

要检查的另一件事是文件的有效性: http ://www.feedvalidator.org/

您还可以检查 API 提供的KmlLayerStatus以查看它报告的内容。

于 2012-08-15T02:16:27.243 回答