I downloaded a payed .mbtiles file from Open Street Map and managed to create nice maps using openmaptiles-server over Kitematic.
However, I would like to use this .mbtiles file as offline repository of tiles in an Android based application I'm writing.
My plans are to have the mbtiles file stored on an SD card, and let osmdroid MapView read it from there.
However, the file doesn't contain (apparently..) the styling information on its own.
My question is how do I add a styling info such as "OSM Bright" or "Klokantech Basic" to my project so the map on my application looks like a proper map
Many thanks
It's not possible to render bitmap tiles on a device just from information contained in mbtiles data file.
What actually is a mbtiles file?
A mbtiles file is just an SQLite database which contains a very little amount of metadata and rendered bitmap images - tiles Those are the same bitmap files you would be serving online from your openmaptiles-server.
Size of mbtiles file versus size of tiles
MBtiles file size should be almost the same as the overall size of all generated files on your mbtiles server (it's the same number of tiles in each zoom level and the same number of pixels in each tile). If you see a significant difference, it may mean that your mbtiles file doesn't contain the same zoom range (e.g. it doesn't actually contain those most detailed zoom levels) or it contains a smaller area. Some difference may be also caused by a compression algorithm of contained bitmaps and here the actual styling of tiles may play some role (some bitmaps may be easier to compress a resulting PNG may be smaller.
It may be also possible, that the mbtiles file actually contains another image format (jpeg).
If you want to explore what is actually contained in the downloaded mbtiles file, try this tool.
Solution
I don't' think there is a solution when you need to use bitmap tiles. You need to either generate them on a server and download them via network, or you need to prerender them and pack into a mbtile file and download that to a device somehow.
One possible solution would be to use vector maps. It's actually possible to generate vector tiles from Openstreetmap data. Such tiles are than rendered on a device and can actually be styled on the device too.
Unfortunately, Osmdroid library does not support vector tiles at the time of writing (AFAIK). You would have to choose a different map rendering library.
Related
I'm new at osmdroid and I'm trying to build simple GPS tracking application that must work offline. So first of all I know that osmdroid works with .osm But how to download osm file directly to my android device and more importantly how later I need to use it. I dont understand .osm file is simply just xml with lots of coordinates and other data. So how that .osm file can be transform to a graphical map? I know that is necessary to parse .osm file to get data, but where to download actual graphical map?
osmdroid does not currently present .osm data, mainly due to performance reasons. osmdroid does render raster images that someone can capture into a zip or database and then transfer to device. The problem really is space. It's a big planet and getting raster images can be huge! You'd have to prepare geographic regions into a database then host them somewhere and have your app download them on demand.
osmdroid as a wiki on offline maps here:
https://github.com/osmdroid/osmdroid/wiki/Offline-Map-Tiles
An alternative approach is something like Mapsforge, which can preconvert .osm data into their own binary format, also chunked up by geographic region. Same rules apply, however the file/download sizes are much smaller. Support for osmdroid using Mapsforge is in beta at the moment, however mapsforge can run on it's own and has it's own demo apps and whatnot.
To transform the .osm file into a graphical map, you need something like renderd and a slew of other tools, all on open street maps wiki. Again, you need a boat ton of storage for the planet to convert it into raster images. Then you'd still have to package them somehow and get them on device.
Or you can just use online maps.
does anyone know if it is possible to build an Android application using osmDroid that makes use of Planet.osm stored on an SD card?
for example, you would store Planet.osm on a large SD card that has been put in a phone. The application loaded on the phone would then look in the SD card for the relevent maptiles and allow the user to have a full map offline.
No, not as you would expect it.
The Planet contains raw vector data whereas osmdroid needs pre-rendered raster tiles. You would need a renderer on your mobile device but rendering is a very ressource-intensive task and not really suited for mobile devices. Unless you are using pre-processed data (and ideally a vector renderer) as done by multiple mobile apps like OsmAnd. Storing pre-rendered tiles could be an option, but only for limited areas as their storage requirements increase very fast.
You can take a look at mapsforge if you intend to add vector rendering to your application.
Brand new to Mapbox.
I'm using the Android SDK version and have local (not cached, nothing from a server) tiles. I would like it if the tiles were not required to be square, but could be rectangular. I'm seeking an example and documentation on how to load local tiles from my assets folder. Right now my tiles are simply stored as .png files in "./assets/map/tiles/zoom/x/y.png" naming convention, but I could change it easily if that helps.
I don't see any examples or documentation anywhere. The code looks like it isn't designed to handle non-square tiles and it isn't clear on what I would do to get my tiles from a local source. I could make my tiles square if that's a problem, but I can't load from a server since the app will be used where there is no data connection.
Thx.
Tiles are required to be square in the Android SDK. While it would be nice to support rectangular, elliptical, etc tile shapes, it would be unclear what geographical area they represented. And computers love squares, very literally - rectangles are performance bottlenecks in some cases. So, you'll need to use squares.
In my android project I want to have offline maps. with tiles my map takes 500 mb of space and I also want to search address on the map offline.
I think the only way to decrease size and make it possible to search , vector maps. How can I use vector maps in OSMdroid ? Where can I get vector maps ?
AFAIK most would use Mapsforge in your case: http://wiki.openstreetmap.org/wiki/Frameworks#Widgets
For reducing the size of tiles you can zip your tiles and copy it to osmdroid folder in sdcard (You must keep current structures of tiles folder).
But you can use KML files in osmdroid as a data source for handling features with
OSMBonusPack to load kml file in osmdroid map.
Also see this example.
I am starting to use Osmdroid and I would like to use this technology for showing a map about an F1 circuit. I have a big picture and I can cut it up to divide it into smaller tiles.
Can I modify the osmdroid library for the upload of these pictures?
I would like to save these bitmaps (tiles) in my assets folder.
I am pretty lost on how to do this.
I am using this way because android, normally, gives a memory error when I try show this complete full-size picture. If I only show some tiles of the image (depends of the zoom) maybe my app would work better?
Thanks in advance!
Osmdroid uses a system in which world map is divided into tiles. Tiles usually have the same pixel size which means that the bigger zoom level you use the more tiles are needed to "cover the world". Each tile has its coordinates (x,y) and a zoom level in which it is designed to be used.
It is possible to use various custom tile sources in osmdroid. Take a look at this class in osmdroid - it creates instances of some tile sources. You can create your own tile sources using the same mechanism. However, all this uses these x,y coordinates of the world I described above. Osmdroid will ask your tile source for example for tile 10,10 in zoom level 10. If you are able to create tiles of your map to work with this coordinates system then it will work. However, it may be hard to do this for custom maps such as F1 circuits.
I am also interested in this and probably will try to use tiling mechanism of osmdroid to display some big images in the near future. If you succeed in this please let me know:).
I think there's two questions here:
How to create osmdroid format map tiles from a bitmap file.
How to load them into osmdroid
For question 1 you can use a tool to create your tiles.
http://www.maptiler.org/
Can be used to create tiles from a bitmap giving in your bitmap and its boundaries coordinates.
http://mobac.sourceforge.net/
Creates Atlas from online maps, it can create osmdroid zip atlas. Not sure if you could use it to create your osmdroid zip format.
If Mobile Atlas creator doesn't help perhaps you can create the zip manually if your source bitmap is not too big.
For question 2:
I extended an osmdroid class to deploy maps in an apk using the asset folder. See here:
https://stackoverflow.com/a/14832770/891479