Osmdroid:如何从我自己的位图(图块)创建和加载地图?
我开始使用 Osmdroid,我想使用这项技术来显示有关 F1 赛道的地图。我有一张大图片,我可以将其切割成更小的图块。
我可以修改osmdroid库来上传这些图片吗?
我想将这些位图(图块)保存在我的资产文件夹中。
我非常不知道如何做到这一点。
我使用这种方式是因为当我尝试显示这个完整的全尺寸图片时,android通常会给出内存错误。如果我只显示图像的一些图块(取决于缩放),也许我的应用程序会工作得更好?
提前致谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Osmdroid 使用将世界地图划分为图块的系统。图块通常具有相同的像素大小,这意味着您使用的缩放级别越大,“覆盖世界”所需的图块就越多。每个图块都有其设计使用的坐标 (x,y) 和缩放级别。
可以在 osmdroid 中使用各种自定义图块源。看看 osmdroid 中的此类 - 它创建一些图块源的实例。您可以使用相同的机制创建自己的图块源。然而,所有这些都使用了我上面描述的世界的 x,y 坐标。 Osmdroid 会询问您的图块源,例如缩放级别 10 中的图块 10,10。如果您能够创建地图图块以使用此坐标系,那么它将起作用。然而,对于 F1 赛道等自定义地图来说,可能很难做到这一点。
我对此也很感兴趣,并且可能会在不久的将来尝试使用 osmdroid 的平铺机制来显示一些大图像。如果你成功了,请告诉我:)。
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:).
我认为这里有两个问题:
对于问题 1,您可以使用工具来创建图块。
可用于从位图创建图块,并给出位图及其边界坐标。
从在线地图创建地图集,它可以创建osmdroid zip地图集。不确定您是否可以使用它来创建 osmdroid zip 格式。
对于问题 2:
https://stackoverflow.com/a/14832770/891479
I think there's two questions here:
For question 1 you can use a tool to create your tiles.
Can be used to create tiles from a bitmap giving in your bitmap and its boundaries coordinates.
Creates Atlas from online maps, it can create osmdroid zip atlas. Not sure if you could use it to create your osmdroid zip format.
For question 2:
https://stackoverflow.com/a/14832770/891479