Leaflet是否有可用的离线Map图层? [英] Is there an offline Map layer available for Leaflet?

查看:293
本文介绍了Leaflet是否有可用的离线Map图层?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可用于Leaflet的离线Map图层?我不需要详细说明,但是基本几何就足够了.

Is there an offline Map layer available for Leaflet? I don't need in detail, but basic geometry would be sufficient.

推荐答案

请确保您可以设置自己的离线地图(栅格图块和/或矢量形状).难易程度或开箱即用的可用性取决于所需的信息类型和详细程度.

For sure you can set up your own offline map (raster tiles and/or vector shapes). The difficulty or out-of-the-box availability depends on what kind of information and level of details you want.

GeoJSON:

最简单的方法是,如果您只需要很少有世界国界的边界,只是为了得到轮廓.在这种情况下,您可以在Internet上找到包含数百kB(单个正常大图像的重量)数据的GeoJSON文件,例如 https://github.com/johan/world.geo.json

The easiest is if you need just world countries borders with little detail, just to get the outline. In that case, you can find GeoJSON files on Internet that contain that data for a few hundreds kB (the weight of a single normal big image), e.g. https://github.com/johan/world.geo.json

然后只需使用L.geoJson(geoJsonData).addTo(map)即可显示它.

Then simply use L.geoJson(geoJsonData).addTo(map) to have it shown.

演示: http://plnkr.co/edit/aB6p7IC2cF7xW41Ju8m7?p=preview

下载的图块:

更复杂的(技术上和合同上)但仍可管理的情况是您是否需要栅格图块(例如OSM网站).您可以从在线服务器下载图块(仅是普通图像),然后离线使用它们.这称为拼贴碎片"或"拼贴碎片批量下载".

A more complex (technically and contractually) but still manageable situation is if you want raster tiles (like the OSM website for example). You can download tiles (which are just normal images) from an online server, then use them offline. This is called "tiles scraping" or "tiles bulk downloading".

对于技术方面(您可能需要下载成千上万张单个图像,具体取决于您要离线使用的缩放级别/细节),有几种软件可供使用(请参阅以上OSM Wiki链接).

As for the technical side (you may have to download thousands of individual images, depending on to which zoom level / details you want to use offline), several software are available (have a look at the above OSM Wiki link).

对于合同方,许多切片服务器(例如,包括OSM)在其使用条款中明确要求不要执行批量下载(因为这会产生很高的需求并在其服务器上使用高带宽).因此,您应该寻找一种可以接受这种用法的服务.

As for the contractual side, many tile servers (including OSM for instance) specifically require in their Terms of Use not to perform bulk downloading (as it generates high demand and uses high bandwidth on their servers). So you should look for a service that accepts this usage.

本地渲染图块:

一种完全授权的解决方案(但技术上最复杂)是下载原始OSM数据 ,并通过软件使用它来生成地图(栅格图块或矢量形状).

A perfectly authorized solution (but the most technically complex) is to download the raw OSM data, and to use it through software to generate your map (whether raster tiles or vector shapes).

您可能会在Internet上找到可以下载简化OSM数据(整个星球的完整数据库已压缩到约30 GB…)或较小地理区域(请参见上面的OSM Wiki链接)的服务.

You can probably find services on Internet that offer to download simplified OSM data (the full database for the entire planet is ~30 GB compressed…) or for a small geographic area (see the above OSM Wiki link).

关于软件,由chrki在问题注释中提供的链接( http://wiki.openstreetmap. org/wiki/Rendering )应该可以帮助您入门.

Regarding the software, the link provided by chrki in the question comment (http://wiki.openstreetmap.org/wiki/Rendering) should get you started.

特别是,您可以很好地生成一次栅格图块,将其保存并摆脱渲染软件,因此可以像刮过它们一样使用这些图块.

In particular, you can very well generate raster tiles once, save them and get rid of the rendering software, so you can use those tiles as if you had scraped them.

这篇关于Leaflet是否有可用的离线Map图层?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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