gpt4 book ai didi

javascript - 单张 map 进度条

转载 作者:行者123 更新时间:2023-12-03 09:33:35 27 4
gpt4 key购买 nike

在等待 map 上渲染图层时,如何显示居中的 map 进度条(带有 %)?

这是我的代码:

<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css" />
<script type='text/javascript' src="http://makinacorpus.github.io/Leaflet.Spin/leaflet.spin.js"></script>
<script type='text/javascript' src="http://makinacorpus.github.io/Leaflet.Spin/spin.js/dist/spin.min.js"></script>
</head>
<body>
<a href="#" onclick="showMap('http://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png')">TF.Landscape</a>&nbsp;|<a href="#" onclick="showMap('http://{s}.tile.thunderforest.com/outdoors/{z}/{x}/{y}.png')">TF.Outdoors</a>
<div id="map" style="width: 640px; height: 480px"></div>
<progress value="0" max="100"></progress>

<script src="http://cdn.leafletjs.com/leaflet-0.7/leaflet.js"> </script>
<script>
var map;
var tileLayer;
function showMap (layerURL) {
if(!map) {
map = L.map('map').setView([19.5, -73], 7);
}

tileLayer = L.tileLayer(layerURL, {
attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a>',
maxZoom: 18
});
//map.addLayer(tileLayer);

map.spin(true);
setTimeout(function () {
map.addLayer(tileLayer);
map.spin(false);
}, 3000);


}
</script>

谢谢!

最佳答案

目前还没有内置或插入的解决方案。所以

  • 如果进度条%不是那么重要,并且您主要想告诉用户正在加载某些内容,您可能需要查看Leaflet.Spin这是一个用于在 map 上显示旋转图标的插件。
  • 如果您确实想要进度条,ma​​rkercluster 插件可能是一个很好的起点。 50k example有这样的进度条。

关于javascript - 单张 map 进度条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31411209/

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