1
我无法获得基本的LeafletJS示例工作。我的日志表明正在导入LeafletJS,并且正在绑定到我的#map div。此外,我的调试器中的网络选项卡确认leaflet.js和leaflet.css正在加载。基本传单示例在浏览器中未显示任何内容
有谁能告诉我我错过了什么吗?我所看到的只是一个空白的白色浏览器窗口。
谢谢!
<!doctype html>
<html>
<head>
<title>A Leaflet map!</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"/>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<style>
#map{ height: 100% }
</style>
</head>
<body>
<div id="map"></div>
<script>
console.log('L', L)
const position = [51.505, -0.09];
const map = L.map('map').setView(position, 13);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
console.log('map', map)
</script>
</body