简体   繁体   English

OpenStreetMap - 用于处理离线地图的java库

[英]OpenStreetMap - java library to handle offline map

I need to create an application that would run on a linux system. 我需要创建一个可以在linux系统上运行的应用程序。 Basically, I want to achieve something like Google Maps, but with much less functionality. 基本上,我希望实现类似Google地图的功能,但功能却少得多。 The application needs to be able to do the followings: 应用程序需要能够执行以下操作:

  • open and display offline maps, as there won't be any internet connection 打开并显示离线地图,因为没有任何互联网连接
  • there will be a static route, like a railway, that has to be displayed, it won't change 将会有一条必须展示的静态路线,如铁路,它不会改变
  • there will be one dynamically changing point, it should be updated 将有一个动态变化的点,它应该更新

I never really developed this kind of an application, I only used Google Maps for android v2, which is quite straight forward, so I wouldn't have any problem, but without internet connection, this isn't an option. 我从来没有真正开发过这种应用程序,我只使用谷歌地图for android v2,这是非常直接的,所以我没有任何问题,但没有互联网连接,这不是一个选项。 So here are my questions: 所以这是我的问题:

  • I downloaded the map in .osm format, which I need. 我以.osm格式下载了地图,这是我需要的。 If I understand correctly, I need to pre-render this files, using something like Mapnik. 如果我理解正确,我需要使用像Mapnik之类的东西预先渲染这些文件。 Is this approach correct? 这种方法是否正确? If yes, how can I use Mapnik for this rendering? 如果是,我如何使用Mapnik进行渲染? If not, what do you recommend? 如果没有,你推荐什么?
  • Let's say I am done with the rendering part. 假设我完成了渲染部分。 If I understand correctly, now I should use something like JMapViewer. 如果我理解正确,现在我应该使用像JMapViewer这样的东西。 I should just import the .jar into my project, then this api would provide a mapview, and with some coding, I can use the api to display my already rendered, offline maps. 我应该将.jar导入到我的项目中,然后这个api将提供mapview,并且通过一些编码,我可以使用api来显示我已经渲染的离线地图。 Is this correct? 这个对吗?

Also, if you can suggest anything, that would help me, I would be grateful. 另外,如果你能提出任何建议,那对我有帮助,我将不胜感激。

Thanks in advance, cheers 在此先感谢,欢呼

basically you have to follow the following steps: 基本上你必须遵循以下步骤:

  • setup a mapnik server load the *.osm file and prerender all tiles you need. 设置mapnik服务器加载* .osm文件并预渲染所需的所有图块。 (store them in some sort of zip archive as the become pretty big in higher zoomlevels, you also fill unused space in the sectors on your harddrive [tar.gz]) (将它们存储在某种类型的zip存档中,因为在较高的缩放级别中变得非常大,您还可以在硬盘上的扇区中填充未使用的空间[tar.gz])
  • write your own class extending from AbstractOsmTileSource to link to the stored data 编写自己的类,从AbstractOsmTileSource扩展到链接到存储的数据
  • write your own class implementing the TileLoader interface to load required tiles from inside the archive 编写自己的类,实现TileLoader接口,从存档中加载所需的tile
  • create instance of JMapViewer and set prev defined TileLoader and TileSource 创建JMapViewer的实例并设置prev定义的TileLoader和TileSource
  • add railway as MapPolygon 添加铁路作为MapPolygon
  • add current position as MapMarker 将当前位置添加为MapMarker

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM