小叶基层控制与非地理图像?

问题描述 投票:0回答:1

我在没有运气的情况下对这个主题进行了多次搜索,所以这是我的问题......

我创建了带有地理地图图块的Leaflet地图,这些图块具有基础图层和覆盖图层的图层控件,并且我创建了带有非地理图像图块的Leaflet图,但是我在创建带有非地理图像的传单图时遇到了问题。具有平铺图层控件 - 因此用户可以在图像之间切换以通过Leaflet图层控制开关查看和放大。

所有设置在没有切片图层控件的单图像版本中都能正常工作,但它们在以下代码中不起作用。我在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>

几天来一直在咀嚼这个。真的很感激你可以引导我朝着正确的方向前进。谢谢...

javascript layer leaflet
1个回答
2
投票

得到它了。原来我混淆了一些L.tileLayer和L.map属性。当我把它拉直,它工作得很好......

© www.soinside.com 2019 - 2024. All rights reserved.