Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Osmdroid: How I can create and load a map from my own bitmaps(tiles)?

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!

like image 836
Juan Pedro Avatar asked Nov 17 '11 16:11

Juan Pedro


2 Answers

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:).

like image 69
Piotr Avatar answered Oct 19 '22 01:10

Piotr


I think there's two questions here:

  1. How to create osmdroid format map tiles from a bitmap file.
  2. 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
like image 41
L. G. Avatar answered Oct 19 '22 00:10

L. G.