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?

Devdatta Tengshe
  • 4,015
  • 10
  • 46
  • 59
  • 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: – mariotomo Feb 15 '18 at 02:46

1 Answers1

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 ));
manimaul
  • 322
  • 3
  • 5
  • http://code.google.com/p/osmdroid/source/browse/trunk/osmdroid-android/src/main/java/org/osmdroid/events/DelayedMapListener.java – manimaul May 08 '13 at 00:04
  • 1
    just a side note: In practice, I ended up setting the delay to 100 ms instead of 1000 – manimaul May 09 '13 at 20:14