我在版本3.1.33上使用SmartyBC。在smarty模板中,leaflet和openstreetmap的代码将不会运行。地图将无法打开。
我已经在{文字} {/literal}之间使用或不使用脚本进行了测试。地图将无法打开。然而,在一个正常的html站点中,代码可以完美地工作。错误出在哪里?
<html>
<head><link rel="stylesheet" type="text/css" href="https://unpkg.com/leaflet@1.5.1/dist/leaflet.css">
<script src='https://unpkg.com/leaflet@1.5.1/dist/leaflet.js'></script>
#map {
height: 500px;
}
</head>
<body>
<div id="map"></div>
<script>
{literal}
var map = L.map('map').setView([43.64701, -79.39425], 15);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
L.marker([51.5, -0.09]).addTo(map)
.bindPopup('A pretty CSS3 popup.<br> Easily customizable.')
.openPopup();
{/literal}
</script>
</body>
</html>没有错误消息和映射。谢谢你的帮助。
发布于 2019-07-07 17:48:36
你没有把# <style>样式放在HTML中。我这样做了,没有{literal}标签的相同代码也可以工作。
https://stackoverflow.com/questions/56916840
复制相似问题