How to get the Map Extent change event in OSMdroid?
Asked Answered
L

1

6

I am using the Osmdroid library in my custom Android App.

At every extent change (& when the map is zoomed in) I want to query the sqlite database and get records that lie within that extent. For this I need something similar to a Map Extent change event.

I could not find such an event on the MapView Class. How Do I achieve what I want to do?

UPDATE I am using the MapListner like this:

mapView.setMapListener(new MapListener() {   
    public boolean onZoom(ZoomEvent arg0) {
        return false;
    }

    public boolean onScroll(ScrollEvent arg0) {
         onExtentChange();
        return false;
    }
} );

but the onScrollEvnt is fired several times for each pan of the map. How do I get the last or final scrollEvent?

Lashelllasher answered 9/4, 2013 at 3:0 Comment(1)
In your edit, you provided yourself a very acceptable answer, but you then also altered the original question, and someone else provided your answer and is getting credit for it. :smile:Bethannbethanne
T
15
setMapListener(new DelayedMapListener(new MapListener() {  
    public boolean onZoom(final ZoomEvent e) {
        //do something
        return true;
    }

    public boolean onScroll(final ScrollEvent e) {
        Log.i("zoom", e.toString());
        return true;
    }
    }, 1000 ));
Thistly answered 8/5, 2013 at 0:2 Comment(2)
code.google.com/p/osmdroid/source/browse/trunk/osmdroid-android/…Thistly
just a side note: In practice, I ended up setting the delay to 100 ms instead of 1000Thistly

© 2022 - 2024 — McMap. All rights reserved.