0
單張是開放源代碼並免費。然而,傳單網站上的示例使用Mapbox渲染地圖。 Mapbox比Google地圖更貴(Mapbox pricing)。 問題是:任何人都可以使用Leaflet真的免費嗎?如何使用Leaflet Map免費?
單張是開放源代碼並免費。然而,傳單網站上的示例使用Mapbox渲染地圖。 Mapbox比Google地圖更貴(Mapbox pricing)。 問題是:任何人都可以使用Leaflet真的免費嗎?如何使用Leaflet Map免費?
您可以免費使用Leaflet庫,只有在示例Mapbox中使用的tileprovider會要求用於投放tile的資金。你只需要一個免費tileprovider像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>