流星上的小叶空白屏幕,但不是单个非流星test.html

时间:2015-08-19 14:44:17

标签: javascript meteor maps leaflet openstreetmap

我在流星上使用传单,但它只显示一张空白(灰色)地图而不显示地图图块。当我在一个单独的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;}。

所以现在我必须使用我的Template.map.rendered函数

运行一些javascript脚本
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 :)");


};

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

1 个答案:

答案 0 :(得分:0)

好吧我弄清楚问题是什么。我有一个reset.css,我的UI有一些重置规则。

这一行产生错误:

leaflet

所以看起来overflow:hidden不喜欢带有<wrappercell borderWidth="0.9f" border="NO_BORDER" colSpan="1"> <phrase font="BOLD_ARIAL"> <token>1234</token> </phrase> </wrappercell> 选项

的div