0
與下面的教程沿着以下:http://leafletjs.com/examples/quick-start/單張地圖不顯示
我下載的CSS和JS的到本地目錄我是從工作,但我只顯示一個灰色背景。沒有地圖。我錯過了什麼?謝謝。
<!DOCTYPE html>
<head>
<meta charset="utf-8" >
<title>Testing Leaflet</title>
<link rel="stylesheet" href="leaflet.css" />
<style>
#mapid { height: 180px; }
</style>
<!--<script src="leaflet.js"></script> -->
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
</head>
<body>
<div id="mapid"></div>
<script>
var mymap = L.map('mapid').setView([51.505, -0.09], 13);
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
maxZoom: 18,
id: 'your.mapbox.project.id',
accessToken: 'your.mapbox.public.access.token'
}).addTo(mymap);
var marker = L.marker([51.5, -0.09]).addTo(mymap);
var circle = L.circle([51.508, -0.11], {
color: 'red',
fillColor: '#f03',
fillOpacity: 0.5,
radius: 500
}).addTo(mymap);
var polygon = L.polygon([
[51.509, -0.08],
[51.503, -0.06],
[51.51, -0.047]
]).addTo(mymap);
</script>
</body>
</html>
Mapbox是使用傳單的必要條件嗎? – martinbshp
不,但你**有**有瓷磚供應商。看看這個:http://leaflet-extras.github.io/leaflet-providers/preview/。 – Shiva127