I'm trying to create a layer with dynamic data. It will look something like a spinning needle on a compass. I want it to show motion using a JavaScript loop which changes the angle of the Polyline. But when executed it does not draw until the loop is complete. It only shows the last layer drawn Viva Video. Any ideas? Here's some code:
for (var i = 0; i < 10; i++) {
var lat1 = lat0 + 1.5 * Math.sin(needle_angle * i);
var lon1 = lon0 + 1.5 * Math.cos(needle_angle * i);
var shapeBoundaryKodiakNeedle = [
new WorldWind.Location(lat0, lon0),
new WorldWind.Location(lat1, lon1)
];
var surfacePolylineKodiakNeedle = new WorldWind.SurfacePolyline(shapeBoundaryK odiakNeedle, new WorldWind.ShapeAttributes(shapeAttribute s));
surfacePolylineKodiakNeedle.highlightAtt ributes = new WorldWind.ShapeAttributes(shapeAttribute s);
needleShapesLayer.removeAllRenderables() ;
needleShapesLayer.addRenderable(surfaceP olylineKodiakNeedle); //WorldWind.RenderableLayer
wwd.redraw();
alert(lat1 + " " + lon1); // Debugging only
}
for (var i = 0; i < 10; i++) {
var lat1 = lat0 + 1.5 * Math.sin(needle_angle * i);
var lon1 = lon0 + 1.5 * Math.cos(needle_angle * i);
var shapeBoundaryKodiakNeedle = [
new WorldWind.Location(lat0, lon0),
new WorldWind.Location(lat1, lon1)
];
var surfacePolylineKodiakNeedle = new WorldWind.SurfacePolyline(shapeBoundaryK odiakNeedle, new WorldWind.ShapeAttributes(shapeAttribute s));
surfacePolylineKodiakNeedle.highlightAtt ributes = new WorldWind.ShapeAttributes(shapeAttribute s);
needleShapesLayer.removeAllRenderables() ;
needleShapesLayer.addRenderable(surfaceP olylineKodiakNeedle); //WorldWind.RenderableLayer
wwd.redraw();
alert(lat1 + " " + lon1); // Debugging only
}