OpenStreetMap-用于处理离线地图的Java库 [英] OpenStreetMap - java library to handle offline map

查看:203
本文介绍了OpenStreetMap-用于处理离线地图的Java库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个可以在linux系统上运行的应用程序.基本上,我想实现类似Google Maps的功能,但功能要少得多.该应用程序需要能够执行以下操作:

I need to create an application that would run on a linux system. Basically, I want to achieve something like Google Maps, but with much less functionality. The application needs to be able to do the followings:

  • 打开并显示离线地图,因为没有任何互联网连接
  • 会有一条静态路线,例如铁路,必须显示,它不会改变
  • 会有一个动态变化的点,应该更新

我从未真正开发过这种应用程序,我只使用了适用于android v2的Google Maps,这非常简单,所以我不会有任何问题,但是如果没有互联网连接,这是不可行的.所以这是我的问题:

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. So here are my questions:

  • 我以所需的.osm格式下载了地图.如果我理解正确,则需要使用Mapnik之类的东西来预渲染此文件.这种方法正确吗?如果是,如何使用Mapnik进行渲染?如果没有,您有什么建议?
  • 假设我已经完成了渲染部分.如果我理解正确,现在应该使用JMapViewer之类的东西.我应该将.jar导入到我的项目中,然后此api将提供一个mapview,并且通过一些编码,我可以使用该api来显示我已渲染的离线地图.这是正确的吗?

此外,如果您能提出任何建议,对我有帮助,我将不胜感激.

Also, if you can suggest anything, that would help me, I would be grateful.

预先感谢,欢呼

推荐答案

基本上,您必须执行以下步骤:

basically you have to follow the following steps:

  • 设置一个 mapnik服务器加载* .osm文件并预渲染所有需要的图块. (将它们存储在某种zip归档文件中,因为在更高的缩放级别中它们会变得非常大,您还会在硬盘驱动器[tar.gz]的扇区中填充未使用的空间)
  • 编写您自己的类,该类从AbstractOsmTileSource扩展为链接到存储的数据
  • 编写自己的类,实现TileLoader接口以从档案内部加载所需的图块
  • 创建JMapViewer实例并设置先前定义的TileLoader和TileSource
  • 将铁路添加为MapPolygon
  • 将当前位置添加为MapMarker
  • setup a mapnik server load the *.osm file and prerender all tiles you need. (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])
  • write your own class extending from AbstractOsmTileSource to link to the stored data
  • write your own class implementing the TileLoader interface to load required tiles from inside the archive
  • create instance of JMapViewer and set prev defined TileLoader and TileSource
  • add railway as MapPolygon
  • add current position as MapMarker

这篇关于OpenStreetMap-用于处理离线地图的Java库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆