我用Tilemill创建了地图,然后用MBUtil提取了瓷砖。
我可以使用Leaflet正确显示图块,但不能成功使用mapbox.js。我正在附加代码,我在做什么错?

任何帮助将不胜感激!

<!DOCTYPE html>
<html>
  <head>
    <title>Leaflet Quick Start Guide Example</title>
    <meta charset="utf-8" />

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!--<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css" />-->
    <link href='https://api.tiles.mapbox.com/mapbox.js/v1.6.2/mapbox.css' rel='stylesheet' />

  </head>
  <body>
    <div id="map" style="width: 1000px; height: 1000px"></div>

    <!-- <script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script> -->
    <script src='https://api.tiles.mapbox.com/mapbox.js/v1.6.2/mapbox.js'></script>
    <script>

      //var tilesUrl = 'http://eccoilmoro.github.io/Mappa-Redditi-IRPEF-2012-/tiles-mappa-   redditi-2012/{z}/{x}/{y}.png',
      //tilesLayer = new L.TileLayer(tilesUrl);
      //map = new L.Map('map');
      //map.addLayer(tilesLayer);
      //map.setView(new L.LatLng(39.5,-5.0), 6);

      var map = L.mapbox.map('map');
      tilesLayer = new L.mapbox.TileLayer({ "tilejson": "2.0.0",
        "tiles": [ "http://eccoilmoro.github.io/Mappa-Redditi-IRPEF-2012-/tiles-mappa-redditi- 2012/{z}/{x}/{y}.png" ] ,
        "attribution": "franco"
      });
      tilesLayer.addTo(map);
      map.setView(new L.LatLng(39.5,-5.0), 6);

    </script>
  </body>
</html>

最佳答案

您可以尝试这种语法

<!DOCTYPE html>
<html>
 <head>
  <title>Leaflet Quick Start Guide Example</title>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href='https://api.tiles.mapbox.com/mapbox.js/v1.6.2/mapbox.css' rel='stylesheet' />
 </head>
<body>
 <div id="map" style="width: 1000px; height: 1000px"></div>

 <script src='https://api.tiles.mapbox.com/mapbox.js/v1.6.2/mapbox.js'></script>
 <script>

  var map = L.mapbox.map('map');
  L.tileLayer('http://eccoilmoro.github.io/Mappa-Redditi-IRPEF-2012-/tiles-mappa-redditi-2012/{z}/{x}/{y}.png', {
   "attribution": "franco"
    }).addTo(map);

  map.setView(new L.LatLng(39.5, 9), 6);
</script>
</body>
</html>

09-25 17:39