如何使用 TileMill 和 Mapbox 的 Mbutil 导出

发布于 2024-10-30 22:48:52 字数 1715 浏览 2 评论 0原文

嘿大家。我只是想弄清楚如何使用我的 mbtile 目录导出。我的文件位于本地目录“/mytiles”中。我如何配置它以使用我的自定义层?

  <head>
    <script src="http://www.openlayers.org/dev/OpenLayers.js"></script>
    <script type="text/javascript">

      var map;
      OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
      OpenLayers.ImgPath = "http://js.mapbox.com/theme/dark/";
      function init(){

        // Customize the values below to change the tileset.
        // This information is available on each tileset page.
        var layername = 'world-light';
        var file_extension = 'png';

        // Build the map
        var options = {
          projection: new OpenLayers.Projection("EPSG:900913"),
          displayProjection: new OpenLayers.Projection("EPSG:4326"),
          units: "m",
          numZoomLevels: 12,
          maxResolution: 156543.0339,
          maxExtent: new OpenLayers.Bounds(
            -20037500,
            -20037500,
            20037500,
            20037500
          )
        };
        map = new OpenLayers.Map('map', options);

        // Layer definitions
        var layer = new OpenLayers.Layer.TMS(
          "MapBox Layer",
          [ "http://a.tile.mapbox.com/","http://b.tile.mapbox.com/",
            "http://c.tile.mapbox.com/","http://d.tile.mapbox.com/" ],
          { 'layername': layername, 'type': file_extension }
        );

        // Add layers to the map
        map.addLayers([ layer ]);

        // Set the map's initial center point
        map.setCenter(new OpenLayers.LonLat(0, 0), 1);
      }

    </script>
  </head>
  <body onload="init()">
    <div id="map" style="width: 500px; height: 300px"></div>
  </body>

Hey all. Im just trying to figure out how to use my mbtile directory export. My files are located in a local directory "/mytiles". How can I configure this to use my custom layer?

  <head>
    <script src="http://www.openlayers.org/dev/OpenLayers.js"></script>
    <script type="text/javascript">

      var map;
      OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
      OpenLayers.ImgPath = "http://js.mapbox.com/theme/dark/";
      function init(){

        // Customize the values below to change the tileset.
        // This information is available on each tileset page.
        var layername = 'world-light';
        var file_extension = 'png';

        // Build the map
        var options = {
          projection: new OpenLayers.Projection("EPSG:900913"),
          displayProjection: new OpenLayers.Projection("EPSG:4326"),
          units: "m",
          numZoomLevels: 12,
          maxResolution: 156543.0339,
          maxExtent: new OpenLayers.Bounds(
            -20037500,
            -20037500,
            20037500,
            20037500
          )
        };
        map = new OpenLayers.Map('map', options);

        // Layer definitions
        var layer = new OpenLayers.Layer.TMS(
          "MapBox Layer",
          [ "http://a.tile.mapbox.com/","http://b.tile.mapbox.com/",
            "http://c.tile.mapbox.com/","http://d.tile.mapbox.com/" ],
          { 'layername': layername, 'type': file_extension }
        );

        // Add layers to the map
        map.addLayers([ layer ]);

        // Set the map's initial center point
        map.setCenter(new OpenLayers.LonLat(0, 0), 1);
      }

    </script>
  </head>
  <body onload="init()">
    <div id="map" style="width: 500px; height: 300px"></div>
  </body>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

余厌 2024-11-06 22:48:52

首先,查看包含 http://a.tile.mapbox.com/ 的代码部分。将其替换为计算机的主机名或本地名称 - 这可能是 http://localhost/http://mycomputer.com/ 等。然后替换 layername与您的图层的名称。

由于这是使用 TMS 层,因此您需要创建一个名为 1.0.0 的目录,该目录位于这两个目录之间 - 如果它们“存在,您需要将图块移到那里”位于名为 mydirectory 的目录中。结果类似于 http://localhost/1.0.0/mydirectory

因此,如果图块的 URL 是 http://localhost/1.0.0/mydirectory/0/0/0.png,您可以

var layer = new OpenLayers.Layer.TMS(
  "MapBox Layer",
  [ "http://localhost/" ],
  { 'layername': 'mydirectory', 'type': 'png' }
);

参考 OpenLayers.org TMS 了解该层的完整文档类型。

First, see the part of the code that includes http://a.tile.mapbox.com/. Replace that with the hostname or local name of your computer - this might be http://localhost/ or http://mycomputer.com/, etc. Then replace layername with the name of your layer.

Since this is using a TMS layer, you'll need to create a directory named 1.0.0 that'll lie in between these two things - you'll need to move your tiles there, if they're in a directory called mydirectory. The result would be like http://localhost/1.0.0/mydirectory.

So, if the URL of a tile is http://localhost/1.0.0/mydirectory/0/0/0.png, you'd have

var layer = new OpenLayers.Layer.TMS(
  "MapBox Layer",
  [ "http://localhost/" ],
  { 'layername': 'mydirectory', 'type': 'png' }
);

You can consult OpenLayers.org TMS for complete documentation of the layer type.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文