If I double Click on my KML file it does what it should and start GE and does as expected. When I put it in to my HTML file it will not work. I then put it into http://earth-api-samples.googlecode.com/svn/trunk/examples/kml-fetch-interactive.html and it doesn't work from there either. This is the link to the KLM https://dl.dropbox.com/u/61240296/myPoints.Kml. It is bascially a direct copy of a Google Sample. Are KML files dependent on other KML files? One thing I have notice is there are no roads so it appears as though non of the KML files are open or active.
<?xml version="1.0" encoding="UTF-8"?>
xmlns:gx="http://www.google.com/kml/ext/2.2"
xmlns:kml="http://www.opengis.net/kml/2.2"
xmlns:atom="http://www.w3.org/2005/Atom">
<Camera>
<longitude>-93.2539393007755</longitude>
<latitude>45.5456585437059</latitude>
<altitude>139.629438</altitude>
<heading>-70.0</heading>
<tilt>75</tilt>
</Camera>
<Placemark>
<name>Placemark from KML file</name>
<Point>
<coordinates>-93.2539393007755, 45.5456585437059</coordinates>
</Point>
</Placemark>
</Document>
</kml>
Your KML file is fine. It also works perfectly in the example page you link to. The problem is the sample page does not change the view after loading your kml file. It doesn't even try to.
Edit this function
function finishFetchKml(kmlObject) {
// check if the KML was fetched properly
if (kmlObject) {
// add the fetched KML to Earth
currentKmlObject = kmlObject;
ge.getFeatures().appendChild(currentKmlObject);
} else {
// 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);
}
}
to look like this
function finishFetchKml(kmlObject) {
// check if the KML was fetched properly
if (kmlObject) {
// add the fetched KML to Earth
currentKmlObject = kmlObject;
ge.getFeatures().appendChild(currentKmlObject);
///////////////////////////////////////////////
// this is what you need to add
var myView = currentKmlObject.getAbstractView();
ge.getView().setAbstractView(myView);
//////////////////////////////////////////////
} else {
// 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);
}
}
Then you need to decide if you want to assign that <Camera>
view to the <Placemark>
or the <Document>
and in case you didn't realise, your <Camera>
view does NOT look at the <Placemark>
it looks at the horizon from a spot directly above the <Placemark>