如何免费使用Leaflet Map?

问题描述 投票:0回答:2

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

google-maps leaflet mapbox
2个回答
36
投票

您可以免费使用Leaflet库,只有示例中使用的tileprovider Mapbox需要付费来提供tile。您只需要一个免费的图块提供程序,例如 OpenStreetMap:

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/[email protected]/dist/leaflet.css" />
  </head>
  <body>
    <div id="leaflet"></div>
    <script type="application/javascript" src="//unpkg.com/[email protected]/dist/leaflet.js"></script>
  </body>
</html>


0
投票

您还可以自定义此地图并删除任何发行水印

© www.soinside.com 2019 - 2024. All rights reserved.