Question

I want to represent 3D models in Google Earth environmente with API and Google Plugin.

I have the code:

  var ge;
  google.load("earth", "1");

  function init() {
     google.earth.createInstance('map3d', initCB, failureCB);
  }

  function initCB(instance) {

     ge = instance;
     ge.getWindow().setVisibility(true);
     ge.getNavigationControl().setVisibility(ge.VISIBILITY_HIDE);

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

    var place2 = ge.createPlacemark('Modello2');
    place2.setName('modello2');

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

    var modello2 = ge.createModel('Mod2');
    place2.setGeometry(modello2);

    // Placemark/Model/Link
    var link = ge.createLink('File1');
    link.setHref("http://myhost.org/table2/models/table2.dae");
    model.setLink(link);

    var link2 = ge.createLink('File2');
    link2.setHref("http://myhost.org/tavolo/models/table2.dae");
    modello2.setLink(link2);

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

    // Placemark/Model/Location
    var loc = ge.createLocation('');
    loc.setLatitude(40.01000594412381);
    loc.setLongitude(-105.2727379358738);
    model.setLocation(loc);

    //slightly varying coordinates...
    var loc2 = ge.createLocation('');
    loc2.setLatitude(40.01000594412389);
    loc2.setLongitude(-105.2727379358731);
    modello2.setLocation(loc2);

    // add the model placemark to Earth
    ge.getFeatures().appendChild(placemark);
    ge.getFeatures().appendChild(place2);

    // zoom into the model

    lookAt.setLatitude(40.01000594412381);
    lookAt.setLongitude(-105.2727379358738);

    lookAt.setRange(300);
    lookAt.setTilt(80);
    ge.getView().setAbstractView(lookAt);

}  

function failureCB(errorCode) {
}

google.setOnLoadCallback(init);

When i load different collada (.dae) files no problems appear... but it doesn't load the same Table 2 times! Why?!?

I have also tried to separate instances and files... but problem persists. I have only one table on my environment.

Is there a method to clone single model into N models ?

Was it helpful?

Solution

have you tried injecting kml t display the models using parse kml.

also try using getKml to get the kml and see if it renders properly in a stand alone kml file

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top