【问题标题】:How to use Leaflet Map for free?如何免费使用传单地图?
【发布时间】:2018-02-13 22:40:15
【问题描述】:

Leaflet 是开源且免费的。然而,传单网站上的示例使用 Mapbox 来渲染地图。 Mapbox 比谷歌地图贵(Mapbox pricing)。 问题是:任何人都可以真正免费使用 Leaflet 吗?

【问题讨论】:

    标签: google-maps leaflet mapbox


    【解决方案1】:

    您可以免费使用 Leaflet 库,只有示例中使用的 tileprovider Mapbox 会为服务图块收取费用。例如,您只需要像 OpenStreetMap 这样的免费 tileprovider:

    var map = new L.Map('leaflet', {
        center: [0, 0],
        zoom: 0,
        layers: [
            new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
                'attribution': 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors'
            })
        ]
    });
    body {
        margin: 0;
    }
    
    html, body, #leaflet {
        height: 100%;
    }
    <!DOCTYPE html>
    <html>
      <head>
        <title>Leaflet 1.0.3</title>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <link type="text/css" rel="stylesheet" href="//unpkg.com/leaflet@1.0.3/dist/leaflet.css" />
      </head>
      <body>
        <div id="leaflet"></div>
        <script type="application/javascript" src="//unpkg.com/leaflet@1.0.3/dist/leaflet.js"></script>
      </body>
    </html>

    【讨论】:

    • 完全免费使用 OSM 磁贴,我只是在看这个页面 - operations.osmfoundation.org/policies/tiles 看起来他们说的不是这样。
    • 澄清 - “未经事先许可,禁止大量使用(例如,分发使用来自 openstreetmap.org 的图块的应用程序).​​.....替代 OpenStreetMap 图块提供商......”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-11-23
    • 2017-05-10
    • 2021-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多