Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restricting the area the user can go to on Mapview

I am using a customised version of the mapview (OSMDroid version). I am using custom tiles within it and I only want the user to be able to view the area where I have my custom tiles. Is there a way to set the boundary lat longs so when they pan the map it doesn't go past these boundaries?

like image 411
Bex Avatar asked Mar 23 '11 10:03

Bex


2 Answers

Update: I know this is an old question, but osmdroid now has a setScrollableAreaLimit() method that will achieve what you are looking for. There is also a setMinZoomLevel() and setMaxZoomLevel() method to easily restrict zoom levels.

Original answer:

Please keep an eye on:

http://code.google.com/p/osmdroid/issues/detail?id=209

A patch has already been created, and will likely be integrated shortly.

like image 125
kurtzmarc Avatar answered Oct 07 '22 08:10

kurtzmarc


This is cross-posted from the osmdroid thread. There's now lists a BoundedMapView class, which implements the afortementioned patch.

For those of use using the .jar or otherwise not that familiar with patches, I cobbled together a subclass of MapView that supports limiting the user's view to a specific area.

Details on how to use it, if not obvious, can be found at http://www.sieswerda.net/2012/08/15/boundedmapview-a-mapview-with-limits/

like image 37
quietmint Avatar answered Oct 07 '22 08:10

quietmint