UnfoldingMap busy looping on draw()

113 Views Asked by At

After some initial trouble, I have now gotten UnfoldingMap to work from Eclipse, as described in the tutorial. This seems to work well, but the draw() method gets repeatedly called at high frequency, causing the CPU to go to 100%. This continues indefinitely, even after the whole map has been drawn. Here is the code for the very simple test app:

public class SimpleMapApp extends PApplet {

    UnfoldingMap map;

    public void setup() {
        size(800, 600);
        map = new UnfoldingMap(this, new Microsoft.AerialProvider());
    }

    public void draw() {
        map.draw();
    }

    public static void main(String[] args) {
        PApplet.main("SimpleMapApp");
    }
}

By putting a sleep() in the draw method, I can see that it has to do with the tile drawing, a couple of tiles are drawn in every call to draw(). I think it also keeps loading map tiles from the server at a high rate; at least Google Maps seems to have banned my IP address, after I used their server in the beginning.

How do I stop the repeated calls to draw() after everything has been drawn?

1

There are 1 best solutions below

4
On BEST ANSWER

There are a couple of options to control how open the draw method gets called:

  1. use frameRate()
  2. manually pause execution using noLoop() and resume it using loop()