在Web项目中使用Android项目中的map.osm和osmarender.xml [英] Using map.osm and osmarender.xml from Android project in web project

查看:146
本文介绍了在Web项目中使用Android项目中的map.osm和osmarender.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前一段时间,我编辑了.osm文件和样式文件(osmarender.xml),并将其包含在Android项目中(使用渗透和Mapsforge库).效果很好,看起来不错.现在,我想在使用OpenLayers(或Leaflet?)的Web项目中重用这些文件.

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?).

使用此示例( https://wiki.openstreetmap.org/wiki/OpenLayers_osm_file_example )我能够显示我的地图(非常本地,但仍为23 MB),但是全部显示为黄色(当然,未应用任何样式),并且在OSM基本地图的顶部进行了渲染.

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.

我要执行以下操作: 1.仅显示我的地图(不需要或不需要其他基本地图). 2.快速显示(但允许平移和缩放). 3.使用我的样式(在osmarender.xml中定义)显示它. 4.仅将其显示到最远(停止在边界框的边界附近平移).

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).

我可以使用OpenLayers(可能是渗透或某些渲染工具)来做到这一点吗?如果是这样,怎么样(大约)?

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

推荐答案

Aarg ... Mapsforge Tile Server是一个很好的提示,但是,正如我今天发现的那样,答案要容易得多.

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

如果您有一个基于Mapsforge库的可运行的Android地图应用程序,则可以让该应用程序生成图块并将其存储在您的移动设备上.例如,您可以从那里复制它们并在带有OpenLayers的Web项目中重复使用它们.

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.

在我的情况下,Android代码(使用Mapsforge 0.5.2)如下:

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());

它将图块写入"mapcache"目录中.

It writes the tiles in the "mapcache" directory.

无论如何,非常感谢你们俩的帮助!

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

这篇关于在Web项目中使用Android项目中的map.osm和osmarender.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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