Search code examples
javascriptgoogle-earthgoogle-earth-plugin

Google Earth KmlModel Altitude


I am using the google earth plugin to manipulate a google earth window within my browser, however I can't seem to change altitude of KmlModels.

The offending script looks like this: (mostly copied from an example)

    var placemark = ge.createPlacemark('');
    placemark.setName('model');

    // Placemark/Model (geometry)
    var model = ge.createModel('');
    placemark.setGeometry(model);

    // Placemark/Model/Link
    var link = ge.createLink('');

    link.setHref('http://earth-api-samples.googlecode.com/svn/trunk/examples/' +
        'static/splotchy_box.dae');
    model.setLink(link);

    // get center look at location
    var lookAt = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);

    // Placemark/Model/Location
    var loc = ge.createLocation('');
    loc.setLatitude(37.929828);
    loc.setLongitude(-100.02596);

    loc.setAltitude(6562); //Has no effect
    model.setLocation(loc);

    // add the model placemark to Earth
    ge.getFeatures().appendChild(placemark);
    // zoom into the model
    lookAt.setRange(300);
    lookAt.setTilt(80);
    lookAt.setLatitude(37.929828);
    lookAt.setLongitude(-100.02596);
    ge.getView().setAbstractView(lookAt);

Does anyone know why? My model is always clamped to the ground no matter what. This is very frustrating.


Solution

  • add code:

    model.setAltitudeMode (ge.ALTITUDE_RELATIVE_TO_GROUND);