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.
Related
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.
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.
i want to make a android app that already has the map tiles of a particular area in its apk and when the user installs the app he can see the map without having an internet connection in his phone. he should be able to see the map of that particular area offline. i have heard i could do this by osmdroid. but can i store actual Googlemaps (satellite view) with it.
Or is it possible to first store the png images of the map tiles of that particular area in your asset folder and then use it. if this is possible can you please tell me how to do this(i mean how to put tiles in asset folder and then display it using inputstream ). i am new to android. any help where to start from?
but can i store actual Googlemaps (satellite view) with it.
OSMDroid does not use Google Maps. There is no API in Maps V2 to cache tiles for offline use, at least not at the present time.
Or is it possible to first store the png images of the map tiles of that particular area in your asset folder and then use it.
You do not have Google Maps' map tiles as PNG images.
i am new to android. any help where to start from?
Use OSMDroid. Or, find some commercial mapping library that offers offline maps.
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
I want to generate a new mapsource from a GeoTIFF file to display it in osmdroid.
I Dont find any solution to convert the GeoTIFF file into the MapSource format osmdroid needs.
You can use Maptiler to generate tiles from your GeoTiff. Then you need to either host these tiles for download somewhere or provide them with your app. Osmdroid allows you to provide the tiles in a zip file, although this did not work for me for very large archives.
You'll then have to add a new tile provider in osmdroid to consume your tiles.
Here's an example of how to provide you own tile source to osmdroid.