我正在尝试使用Leaflet制作离线贴图。在小册子中显示来自其他缩放级别的瓷砖
为了保存数据,用户可以选择不保存所有缩放级别。举例用户具有zoomlevels: - 15和17
现在的问题是,当用户从15级缩放到16
如何显示级别15(或17)从16缩放层?
另一种方法是跳过缩放级别16,但也许有另一种选择? 我从传单中查看源代码,但我无法弄清楚。
Update Fiddle与插件,跳过缩放级别(由ILJA兹韦列夫)
HTML
<div id="map"></div>
<div id="out"></div>
javascipt的
var map = L.map('map').setView([52.084, 5.11], 15);
isNoZoomlevel = 16;
L.tileLayer('http://a.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://openstreetmap.org">OpenStreetMap</a>',
maxZoom: 18
}).addTo(map);
map.on('zoomend', function() {
console.log("I zoomed to level " + map.getZoom());
if(map.getZoom() == isNoZoomlevel) {
console.log("This offline zoomlevel does not excist");
$("#out").html("This is no zoomlevel");
// Howto replace the zoomlevel 16 with 17 or 15??
} else {
$("#out").html("");
}
});
CSS
#map {
height: 250px;
}
试过了......像魅力一样工作 – YaFred
是的。感谢您的好插件。 唯一的问题是,它不会显示缩放级别16级别15的图块。它只是跳过缩放级别16.因此,当您只有3个缩放级别时,它会放大到极限......我将学习如何编写插件。也许我可以为你的github做出贡献.. –
我想让它变成这样: http://jsfiddle.net/zoutepopcorn/7a3xe/17/ –