I wrote a simple initCB() function with a loop to time the loading.
(Note that I used a "." to help indent the code on the forum).
function initCB(instance) {
....ge = instance;
....ge.getWindow().setVisibility(true);
....
....var startTime = new Date().getTime();
....
....for( var iLp=0; iLp<500; iLp++ ) {
........// Create the placemark.
........var placemark = ge.createPlacemark('');
........
........// Set the placemark's location.
........var point = ge.createPoint('');
........point.setLatitude(40 + (iLp*0.01));
........point.setLongitude(-111 + (iLp*0.01));
........placemark.setGeometry(point);
........
........// Set the placemark's name.
........placemark.setName( 'Mark #'+iLp );
........
........// Add the placemark to Earth.
........ge.getFeatures().appendChild(placemark);
....}
....
....var elapsedTime = new Date().getTime() - startTime ;
....alert( "Loading time: " + elapsedTime );
....
....// Create a new LookAt
....var lookAt = ge.createLookAt('');
....// Set the position values
....lookAt.setLatitude(40);
....lookAt.setLongitude(-111);
....lookAt.setRange(20000.0);
....
....// Update the view in Google Earth
....ge.getView().setAbstractView(lookAt);
}
Any ideas why the load times are so different?
Thanks!
> > Thanks!- Hide quoted text -
>
> - Show quoted text -
While it would seem parseKml has obviously speeded things up for you
another way, if ever needed, is to use the google.earth.executeBatch()
function. This allows you to do lots of updates and have ge add all
the features in one hit.
Example at
http://earth-api-samples.googlecode.com/svn/trunk/examples/batch.html
In your code
google.earth.executeBatch(ge, function () {
for( var iLp=0; iLp<500; iLp++ ) {
...etc etc
}
});
Regards
Nymor