In the source I attached to my previous post I included another class I recently created which is based on a patch from Marc Kurtz and Zoran Nikolic (see here for details). Actually, it’s more than just based on their code: I copied quite a bit of their work, so credits where credit’s due.
Anyway, essentially the class allows you to set limits to the area that can be viewed. This is useful if you supply an offline map database that only contains a specific area, a city for example. The class itself is called BoundedMapView.java. A class that illustrates the usage is below the break (for information on MBTileProvider see the previous post as well).
A couple of days ago I posted an example of getting osmdroid to work with an offline MBTiles database. The example is quite elaborate, mostly because 80% of it is comment, not code. I found three issues with this:
- The amount of text between the lines of actual code is so big, that it makes it hard to follow, but …
- This is necessary because the steps don’t really speak for themselves and …
- Even if you remove all the comments, you still end up with more lines of code than you should
So I thought I’d remedy this by extending the framework. As a result I updated RouteMapActivity.java and created three new classes:
Below you’ll find the code to these classes. Please note that you have to make sure that they are put in the correct package for things to work. You can also download the sources.