Aloha all,
I'm attempting to use the parseKml function to load up a tour to the
google earth object. Below is the code. I'm getting an "Error calling
method on NPObject!" on the "var kmlObject = ge.parseKml(kmlString);"
line, in the PreviewTour function. I am using my own KML string, but
as a result of this error I have been testing using the KML from the
API Docs just in case my string is incorrectly formatted or something.
Not sure what else to include here. Please let me know what other
information I might need to provide.
Thanks,
Chris
----------------------------------------------------------------------------------------
google.load("earth", "1");
var ge;
var tour;
function init() {
google.earth.createInstance("map3d", initCallback,
failureCallback);
}
function initCallback(object) {
ge = object;
ge.getWindow().setVisibility(true);
var layerRoot = ge.getLayerRoot();
layerRoot.enableLayerById(ge.LAYER_TERRAIN, true);
layerRoot.enableLayerById(ge.LAYER_ROADS, false);
layerRoot.enableLayerById(ge.LAYER_BUILDINGS, true);
layerRoot.enableLayerById(ge.LAYER_BUILDINGS_LOW_RESOLUTION,
true);
layerRoot.enableLayerById(ge.LAYER_BORDERS, false);
var navControl = ge.getNavigationControl();
navControl.setVisibility(ge.VISIBILITY_SHOW);
var la = ge.createLookAt('');
la.set(12.345678, 12.345678, 0,
ge.ALTITUDE_RELATIVE_TO_GROUND, 50, 60, 1500);
ge.getView().setAbstractView(la);
}
function failureCallback(errorCode) {
alert("Failure loading the Google Earth Plugin: " +
errorCode);
}
function PreviewTour() {
var kmlString = ''
+ '<?xml version="1.0" encoding="UTF-8"?>'
+ '<kml xmlns="
http://www.opengis.net/kml/
2.2">'
+ '<Document>'
+ ' <Camera>'
+ ' <longitude>-122.444633</longitude>'
+ ' <latitude>37.801899</latitude>'
+ ' <altitude>139.629438</altitude>'
+ ' <heading>-70.0</heading>'
+ ' <tilt>75</tilt>'
+ ' </Camera>'
+ ' <Placemark>'
+ ' <name>Placemark from KML string</
name>'
+ ' <Point>'
+ '
<coordinates>-122.448425,37.802907,0</coordinates>'
+ ' </Point>'
+ ' </Placemark>'
+ '</Document>'
+ '</kml>';
var kmlObject = ge.parseKml(kmlString); //this line throws the
error
tour = ge.getFeatures().appendChild(kmlObject);
ge.getTourPlayer().setTour(tour);
ge.getTourPLayer().play();
}