Osmdroid: How I can create and load a map from my

2019-03-28 10:41发布

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!

2条回答
冷血范
2楼-- · 2019-03-28 11:18

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:

查看更多
聊天终结者
3楼-- · 2019-03-28 11:21

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

查看更多
登录 后发表回答