Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

draw is being constantly called in my android map overlay

I'm trying to draw a route onto my MapView. I've extended Overlay and implemented the draw() method. The route is displayed properly, although while debugging, I added a breakpoint on draw(), and noticed it is being called constantly.

I only want it to be re-drawn if someone moves the map or zooms (the draw take into account these changes when drawing the route) What can cause this ?

like image 208
Itsik Avatar asked May 07 '10 23:05

Itsik


1 Answers

There are two draw methods that can be overridden.

void draw(android.graphics.Canvas canvas, MapView mapView, boolean shadow)

Desc: Draw the overlay over the map.

boolean draw(android.graphics.Canvas canvas, MapView mapView, boolean shadow, long when)
Desc: Draw call for animated overlays.

I originally overrided the second one.
After changing to the first method, it worked out.

like image 122
Itsik Avatar answered Nov 07 '22 12:11

Itsik