Hello Everybody,
I am trying to draw a road incrementally as an animation over GE plugin. I have a set of coordinates (lat,long) in an array and I am using the following function in a loop at small time intervals to draw the entire road in small parts animatedly.
var intFeatureCounter4Trace=0
function createPath(lat1,lng1,lat2,lng2,strToolType){
lineStringPlacemark = ge.createPlacemark('');
var lineString = ge.createLineString('');
lineStringPlacemark.setGeometry(lineString);
lineString.setTessellate(true);
lineString.getCoordinates().pushLatLngAlt(lat1,lng1,0);
lineString.getCoordinates().pushLatLngAlt(lat2,lng2,0);
lineStringPlacemark.setStyleSelector(ge.createStyle(''));
var lineStyle=lineStringPlacemark.getStyleSelector().getLineStyle();
lineStyle.setWidth(5);
lineStyle.getColor().set("9900FFFF"); //'aabbggrr' format
intFeatureCounter4Trace+=1;
ge.getFeatures().appendChild(lineStringPlacemark);
}
While drawing the road in small parts I am keeping track of the number of small line segments that are added to the GE plugin and use this feature count to remove all the added line segements in a loop using the following function :-
function clearPath(){
for(var i=0;i<intFeatureCounter4Trace;i++){
ge.getFeatures().removeChild(ge.getFeatures().getLastChild());
}
}
The problem is for a large number of (lat,longs) say 20,000 or so, the clearPath() function hangs the browser and sometimes some features that are not to be removed are also removed. Is there a way to remove all the smaller segments in one go? i.e, Is there a way to append all smaller segments part by part (as animation) to a single feature and then remove it in one go from the GE plugin DOM instead of removing it part by part?
Regards,
Shiva