我对此主题进行了多次搜索,但没有成功,所以这是我的问题...
我已经使用地理 map 图 block 创建了传单 map ,这些 map 图 block 具有基础层和覆盖层的图层控件,并且我已经使用非地理图像图 block 创建了传单 map ,但我在使用非地理图像创建传单 map 时遇到了问题图像还具有图 block 图层控件 - 因此用户可以通过 Leaflet 图层控制开关在图像之间切换以查看和放大。
所有设置在没有图 block 图层控制的单图像版本中都可以正常工作,但在以下代码中不起作用。我已经在 Dreamweaver 和 Firebug 中运行了代码检查器,他们没有发现任何错误,但我得到的是一个空白屏幕,没有图像,没有可见的图层控件,并且右下角没有图层属性。
<!DOCTYPE html>
<html>
<head>
<title>Horsehead Nebulae</title>
<meta charset="utf-8"/>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.ie.css" />
<![endif]-->
<script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"></script>
<script>
function init() {
var mapMinZoom = 0;
var mapMaxZoom = 5;
var map = L.map('map', {
maxZoom: mapMaxZoom,
minZoom: mapMinZoom,
crs: L.CRS.Simple
}).setView([0, 0], mapMaxZoom);
var mapBounds = new L.LatLngBounds(
map.unproject([0, 5376], mapMaxZoom),
map.unproject([5120, 0], mapMaxZoom));
map.fitBounds(mapBounds);
var hhAttr = 'Ipsulem lorem',
hhUrl = 'http://www.astonisher.com/maps/nebulae/horsehead/{z}/{x}/{y}.png';
var horsehead = L.tileLayer(hhUrl, {attribution: hhAttr});
var heAttr = 'Ipsumel lorem',
heUrl = 'http://www.astonisher.com/maps/nebulae/helix/{z}/{x}/{y}.png';
var helix = L.tileLayer(heUrl, {attribution: heAttr});
var map = L.map('map', {
minZoom: mapMinZoom,
maxZoom: mapMaxZoom,
bounds: mapBounds,
noWrap: true,
layers: [horsehead]
});
var baseLayers = {
"Horsehead": horsehead,
"Helix": helix
};
L.control.layers(baseLayers).addTo(map);
}
</script>
<style>
html, body, #map { width:100%; height:100%; margin:0; padding:0; }
</style>
</head>
<body onLoad="init()">
<div id="map"></div>
</body>
</html>
这几天一直在思考这个问题。真的很感激你能引导我走向正确的方向。谢谢...
最佳答案
明白了。结果我混淆了几个 L.tileLayer 和 L.map 属性。当我弄清楚这一点后,效果很好......
关于javascript - 具有非地理图像的传单基础层控制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22115442/