admin管理员组文章数量:1426102
Following along with the following tutorial: /
I downloaded the css and the js to a local directory that I'm working from but I'm only showing a gray background. No map. What am I missing? Thank you.
<!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="/[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('/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
attribution: 'Map data © <a href="">OpenStreetMap</a> contributors, <a href=".0/">CC-BY-SA</a>, Imagery © <a href="">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>
Here is all that is displayed.
Following along with the following tutorial: http://leafletjs./examples/quick-start/
I downloaded the css and the js to a local directory that I'm working from but I'm only showing a gray background. No map. What am I missing? Thank you.
<!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./[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./v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
attribution: 'Map data © <a href="http://openstreetmap">OpenStreetMap</a> contributors, <a href="http://creativemons/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.">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>
Here is all that is displayed.
Share Improve this question asked Mar 16, 2017 at 13:10 martinbshpmartinbshp 1,1834 gold badges25 silver badges37 bronze badges1 Answer
Reset to default 5 L.tileLayer('http://{s}.tile.osm/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm/copyright">OpenStreetMap</a> contributor',
//other attributes.
}).addTo(mapname);
I was facing the same issue, edit/add this to your existing code. You don't need to setup any account.
本文标签: javascriptLeaflet map not displayingStack Overflow
版权声明:本文标题:javascript - Leaflet map not displaying - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745468963a2659660.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论