gpt4 book ai didi

javascript - meteor 上的传单空白屏幕,但单个非 meteor test.html 上没有

转载 作者:行者123 更新时间:2023-11-28 07:01:35 24 4
gpt4 key购买 nike

我在 meteor 上使用传单,但它只显示空白(灰色) map ,而不显示 map 图 block 。当我在单个 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>

但是当我尝试在 meteor 中执行此操作时它不起作用。我的 meteor 设置:

我有一个 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>

我也使用iron:router来路由。所以有一个带有 map 模板的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 :)");


};

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

最佳答案

好吧,我知道问题出在哪里了。我有一个 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

关于javascript - meteor 上的传单空白屏幕,但单个非 meteor test.html 上没有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32098713/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com