Using map.osm and osmarender.xml from Android project in web project

北城以北 提交于 2019-12-12 13:38:52

问题


I edited an .osm file and a style file (osmarender.xml) some time ago and included it in an Android project (using osmosis and the Mapsforge library). Works fine and looks good. Now I would like to reuse these files in a web project using OpenLayers (or Leaflet?).

Using this example (https://wiki.openstreetmap.org/wiki/OpenLayers_osm_file_example) I was able to display my (very local, but still 23 MB) map, however, it was all in yellow (no styles applied, of course) and it was rendered on top of the OSM base map.

I want to do the following: 1. Display my map only (no other base map needed or wanted). 2. Display it fast (yet allowing for panning and zooming). 3. Display it using my styles (defined in the osmarender.xml). 4. Display it only as far as it goes (stop panning close to the borders of the bounding box).

Can I do this with OpenLayers (and probably osmosis or some rendering tool)? And if so, how (just about)?


回答1:


You could just pre-render all required tiles using Maperitive, TileMill or a similar application. It can't get any faster. Also take a look at the various rendering softwares for OSM.




回答2:


MOBAC (2.0 Alpha 4) and Mapsforge Tile Server can render raster tiles based on a mapsforge style and map file. The tiles/server can be used in other applications like Leaflet or OpenLayers.

Not sure how stable and mature these are though, MOBAC is still alpha and MTS had an issue with clipped labels and no Windows support.

See also mapsforge OSM Wiki page.




回答3:


Aarg ... Mapsforge Tile Server is a good hint, however, the answer is much easier as I found out today.

If you have a working Android map application based on the Mapsforge library you can have this application produce tiles and store them on your mobile device. From there you can copy them and reuse them in a web project with OpenLayers, for example.

The Android code (with Mapsforge 0.5.2) is in my case as follows:

TileCache tileCache = AndroidUtil.createTileCache(activity, "mapcache",
            mapView.getModel().displayModel.getTileSize(), this.getScreenRatio(),
            mapView.getModel().frameBufferModel.getOverdrawFactor());

It writes the tiles in the "mapcache" directory.

Anyway, thank you very much for the help of both of you!



来源:https://stackoverflow.com/questions/33414264/using-map-osm-and-osmarender-xml-from-android-project-in-web-project

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