宣传单/ OSM地图无法在我的网站上使用,为什么?

Cha*_*son 0 wordpress openstreetmap leaflet

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 &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors',
    maxZoom: 18,
});.addTo(mymap);
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

JAT*_*T86 5

您的代码包含一个不需要的分号,导致错误:

});.addTo(mymap)
Run Code Online (Sandbox Code Playgroud)

它应该是:

}).addTo(mymap);
Run Code Online (Sandbox Code Playgroud)