传单空白屏幕上的流星,但不是在单一的非流星测试.html



我在流星上使用传单,但它只显示空白(灰色)地图,而不显示地图瓦片。当我在单个html文件中本地测试脚本时,它可以工作。

<html>
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
</head>
<body>
test
<div id="map" style="height: 180px;"></div>
123
<script>
    var map = L.map('map').setView([51.505, -0.09], 13);

    L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
        maxZoom: 18
    }).addTo(map);
    var marker = L.marker([51.5, -0.09]).addTo(map);
    marker.bindPopup("some text :)");
</script>
</body>
</html>

但是当我尝试在流星中这样做时,它不起作用。我的流星设置:

我有一个main.html,我声明了一些cdn:

<head>
    <script src="http://cdn.leafletjs.com/leaflet-1.0.0-b1/leaflet.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
    <meta name="viewport" content="width=device-width, initial-scale = 1.0, user-scalable = no">
    <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-1.0.0-b1/leaflet.css"/>
</head>

我也使用铁:路由器路由。这里有一个map。html和一个地图模板其中只有

<div id="map"></div>

我还在样式表中设置了#map{height: 180px;}。

现在我要用javascript来运行这个脚本使用template。map。rendered函数

Template.map.rendered = function () {
    var map = L.map('map').setView([51.505, -0.09], 13);
    L.Icon.Default.imagePath = "/images/leaflet/";

    L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
        maxZoom: 18
    }).addTo(map);
    var marker = L.marker([51.5, -0.09]).addTo(map);
    marker.bindPopup("some text :)");

};

但它不会工作。是什么导致空白地图错误?浏览器控制台没有显示任何错误

好了,我知道问题出在哪里了。我有一个reset.css,里面有一些UI的重置规则。

这一行产生了错误:

div, a, p, img, blockquote, form, fieldset, textarea, input, label, iframe, code, pre {
    some stuff,
    some stuff,
    overflow:hidden;   <---------
}

所以看起来leaflet不喜欢带有overflow:hidden选项的div

最新更新