stackoverflow上的某个人试图帮助我在我的网站上实现OSM。代码snippit在这里运行正常,但我的网站页面上没有显示任何内容,请访问www.livehazards.com/sidebar-test。有谁知道问题是什么。感谢
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.2.0/dist/leaflet.css"
integrity="sha512-M2wvCLH6DSRazYeZRIm1JnYyh22purTM+FDB5CsyxtQJYeKq83arPe5wgbNmcFXGqiSH2XR8dT/fJISVA1r/zQ=="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.2.0/dist/leaflet.js"
integrity="sha512-lInM/apFSqyy1o6s89K4iQUKg6ppXEgsVxT35HbzUupEVRh2Eu9Wdl4tHj7dZO0s1uvplcYGmt3498TtHq+log=="
crossorigin=""></script>
<style>
body { margin:0; padding:0; }
#mapid { position:absolute; top:0%; bottom:0%; left:0%; width:100%; }
</style>
</head>
<body>
<div id='mapid'></div>
<script>
var mymap = L.map('mapid').setView([51.505, -0.09], 13);
L.tileLayer('http://a.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors',
maxZoom: 18,
});.addTo(mymap);
</script>
</body>
</html>
答案 0 :(得分:5)
您的代码包含导致错误的不需要的分号:
});.addTo(mymap)
应该是:
}).addTo(mymap);