kmz file not displayed in google earth plugin - have to zoom and dezoom to get it displayed

StackOverflow https://stackoverflow.com/questions/14165327

Вопрос

I have to display large kml files into my website with the google earth plugin. The model seems to be always correctly downloaded but not displayed: sometimes i have to right click on the plugin like 5 or 6 times to see the model being displayed. after that it is corrctly displayed if i reload the page.

i'm using the following code:

<script type="text/javascript" >
google.load("earth", "1");
var ge;
function init() {
    google.earth.createInstance('map3D', initCB, failureCB);
}

function initCB(instance) {
    ge = instance;
    ge.getWindow().setVisibility(true);
    ge.getNavigationControl().setVisibility(ge.VISIBILITY_SHOW);

    google.earth.fetchKml(ge, "<?php echo $kmz ?>", function(kmlObject) {
        if (kmlObject)
            {
                var la = ge.createLookAt('');
                la.set(<?php echo $lat ?>, <?php echo $long ?>, <?php echo $alt+500 ?>, ge.ALTITUDE_RELATIVE_TO_GROUND, 0, 45, 10);
                ge.getView().setAbstractView(la);

                ge.getFeatures().appendChild(kmlObject);


            }
    });


 }
     function failureCB(errorCode) {
        alert("failure");
}

google.setOnLoadCallback(init);  
</script>

i also tried to use createNetworkLink but the problem remains. What should i change to get it work?

thanks!

Это было полезно?

Решение

It is simply the model taking time to load into the plug-in that is causing the problem. I have tested it in a number of browsers on a few OSs and the behaviour is the same in all cases.

The reason it works on subsequent page reloads is that the plug-in is caching the data so it isn't actually fetching the data a second time.

The zooming out, zooming in isn't doing anything to load the model any faster - it is simply passing the time until it loads.

On every test I have done the model always loads - but can take between 2 and 10 seconds to display...

There isn't a great deal you can do about this other than to try and optimise the .dae and image file within your KMZ archive to reduce the file size. This will make the model load and display faster than it currently does.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top