Hi,
I want to implement a function like this: http://matti.virtuallypreinstalled.com/ol-demo/VectorAnimation. I have checked the code:https://code.google.com/p/vopenlayers/source/browse/trunk/src/test/java/org/vaadin/vol/demo/VectorAnimation.java. I want to add a polyline on the map per second. In a button-click listener function, I start a new thread to run the add-polyline function. But the polylines always show together at the last second. Does anyone know why about this or can anyone give me some suggestions or some source code?
Here is my code:
button.addListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
for(int i = 1; i<3;i++){
Thread draw = new Thread(new Draw(i));
draw.start();
}
}
class Draw implements Runnable{
private int i;
public Draw( int i){
this.i = i;
}
@Override
public void run() {
// TODO Auto-generated method stub
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
synchronized (getApplication()){
mapComponent.drawLineTest(i);
}
}
}
});
Thanks very much for any help.
Zhiyong