OpenStreetMap - java library to handle offline map

偶尔善良 提交于 2019-12-11 19:20:12

问题


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:

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

  • I downloaded the map in .osm format, which I need. If I understand correctly, I need to pre-render this files, using something like Mapnik. Is this approach correct? If yes, how can I use Mapnik for this rendering? 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. 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. Is this correct?

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

Thanks in advance, cheers


回答1:


basically you have to follow the following steps:

  • 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


来源:https://stackoverflow.com/questions/17403547/openstreetmap-java-library-to-handle-offline-map

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!