matthias
matthias

Reputation: 199

android mapview - attach to something like "onZoom"

i want to update a polygon i draw on the mapview for every zoomlevel. how can i get a notivication when mapview is zoomed in or out?

BR

Upvotes: 1

Views: 144

Answers (1)

Pavel Dudka
Pavel Dudka

Reputation: 20944

Unfortunately there is no native callback which notifies you about zoom level change. What you can do - is extend native map view and look for zoom level change inside onDraw method:

public final class CustomMapView extends MapView
{
    private int lastZoomLevel = -1;


    @Override
    public void draw(Canvas canvas) 
    {
        if (isZoomChange()) 
        {
            lastZoomLevel = this.getZoomLevel();
            onZoomLevelChange(lastZoomLevel); //this would be your notification function
        }
        super.draw(canvas);
    }

    private boolean isZoomChange() 
    {
        return (getZoomLevel() != lastZoomLevel);
    }
}

Upvotes: 3

Related Questions