这是我的问题:我想从我的本地服务器使用kml文件,但它不起作用。
这是我的代码:
function initialize() {
var chicago = new google.maps.LatLng(48.807,2.137);
var mapOptions = {
zoom: 11,
center: chicago
}
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var ctaLayer = new google.maps.KmlLayer({
url: '78.kml'
});
ctaLayer.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
我在这个网站上尝试了我的kml文件并且工作正常
现在可以使用此代码:
<script type="text/javascript" src="http://geoxml3.googlecode.com/svn/branches/polys/geoxml3.js"></script>
<script type="text/javascript">
function initialize() {
var chicago = new google.maps.LatLng(48.807,2.137);
var mapOptions = {
zoom: 11,
center: chicago
}
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var myKmlOptions = {
preserveViewport: true,
suppressInfoWindows: true
}
var myParser = new geoXML3.parser({map: map});
myParser.parse('78.kml');
//var ctaLayer = new google.maps.KmlLayer("http://localhost/monDossier/78Yvelines.kml",{color:"#4385F1" } );
//ctaLayer.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>