0
我正在关注leaftlet js入门教程。但我无法加载地图。这里是我的代码有无法加载leaftlet地图
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
</head>
<style>
#mapid { height: 180px; }
</style>
<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: 'I have put public access token'
}).addTo(mymap);
</script>
<body>
<div style="margin-top:100px;margin-left:100px;height: 200px;width:200px" id="mapid"></div>
<div style="height:200px;width:200px;background: red">
</div>
</body>
</html>
在上面的代码,id: 'your.mapbox.project.id'
我无法找到。我发现只有公共访问令牌,就是这个原因地图是没有得到加载..任何帮助表示赞赏
或者,使用不同的tile服务,例如'var positron = L.tileLayer('http:// {s} .basemaps.cartocdn.com/light_all/{z}/{x}/{y}。 png',{归属地:'© OpenStreetMap贡献者,© CartoDB'})。addTo(map);' – IvanSanchez