0

I am looking for a way to read my Offline MBtiles and find bounding box in terms of latitude and Longitude at Runtime. I do not want to hard code the bounding box. I want to be able to read from MBTiles file and figure out the center based on top left and bottom right's lat and long values. It assumes map is rectangular (it is good assumption). It is simple trig mid point calculation.

 MapView.getBoundingBox

This only returns bounding box of map on display in screen. I need to be read bounding box of entire Offline .Mbtiles map file.

Also, how would I read at runtime max zoom and min zoom of .mbtiles file?

user914425
  • 16,303
  • 4
  • 30
  • 41
  • Did you read the [specification](https://github.com/mapbox/mbtiles-spec/blob/master/1.1/spec.md)? – CL. Jul 22 '15 at 19:31

1 Answers1

0

AFAIK, MBTiles is just a Sqlite database with a different extension. Meaning you can do some queries such as

select max(z) from tiles; //max zoom level

select min(z) from tiles; //min zoom level

Getting the bounds it a bit trickier since you'll have to translate from the X,Y coordinate system to a Lat/Lon (this is what you want, right?)

Run the same queries above to get the min/max X and Y values. Then run one of the algorithms posted on the OSM wiki, such as this http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Tile_bounding_box to translate back to Lat/Lon.

I'm pretty sure this is implemented in OsmDroid already, so all you need is a function call.

spy
  • 3,199
  • 1
  • 18
  • 26