I am doing a test and need to run KML files from local web server.
When I go to the
http://localhost, I can see my HTML with google maps.
When I click on a particular state, the KML for that state loads. This
works fine on a public web server but not on local web server. I am
running windows server 2003 and IIS. It says Bad or Null KML. There is
something with the path. Does anyone know why? Please see my code
below.
I can browse and view the KML file locally using the path listed on
var kmlurl
document.getElementById('curr_reg').innerHTML="Pennsylvania";
// loadKml1('test.kml');
loadKml1('test.kml');
function loadKml1(file) {
// var kmlUrl = '
http://earth-api-samples.googlecode.com/svn/
trunk/' +'examples/static/' + file;
var kmlUrl ="
http://localhost/KML/"+file;
//alert(kmlUrl);
//alert(kmlUrl);
// fetch the KML
google.earth.fetchKml(ge, kmlUrl, function(kmlObject) {
// NOTE: we still have access to the 'file' variable (via JS
closures)
if (kmlObject) {
// show it on Earth
currentKmlObjects[file] = kmlObject;
ge.getFeatures().appendChild(kmlObject);
} else {
// bad KML
currentKmlObjects[file] = null;
// wrap alerts in API callbacks and event handlers
// in a setTimeout to prevent deadlock in some browsers
setTimeout(function() {
alert('Bad or null KML.');
}, 0);
// uncheck the box
// document.getElementById('kml-' + file + '-check').checked =
'';
}
});
}