【问题标题】:leaflet set path to local map tiles works offline but not online传单设置本地地图图块的路径离线工作,但不能在线
【发布时间】:2015-03-23 17:21:38
【问题描述】:

我想离线使用地图图块。瓷砖是用 Maperitive 制成的。这是带有传单 JS 的 HTML:

<!DOCTYPE HTML>
<html>
  <head>
    <title>map - test</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge">

        <!-- leafletjs -->
        <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
        <script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>

        <style>
            body {
                margin: 0;
                padding: 0;
            }
            html, body, #map {
                height: 100%;
                width: 100%;
            }
        </style>
</head>

<body>
    <div id="map">
        <script>

            var map = L.map('map', {
                maxZoom: 18,
                minZoom: 16,
                maxBounds: [
                    //south west
                    [47.918760313911896, 9.25198432059355],
                    //north east
                    [47.929235549307315, 9.26072925925386]
                ], 
            }).setView([47.923997931609605, 9.2563567899237054], 17);

            L.tileLayer('../img/tiles/{z}/{x}/{y}.png', {  
                tms: true // Do I need that?
            }) .addTo(map);

            L.marker([47.92458, 9.25630]) .addTo(map);

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

代码在我的计算机上离线工作,但在我的服务器上不在线。带有图块的文件夹存储在服务器上。瓷砖的路径是正确的。

我的错是什么?

【问题讨论】:

    标签: maps leaflet tile


    【解决方案1】:

    我找到了原因。

    这不是代码。 tile-PNG 导致 403 错误。我在 Windows 8 计算机上使用 Maperitive 渲染了瓷砖。然后我将它们转移到 Mac 上。从那里我通过 ftp 将它们放在服务器上。

    现在我将图块直接从 Windows 传输到服务器。 一切正常

    在 Windows 和 Mac 之间会发生什么会损坏 PNG?

    【讨论】:

      猜你喜欢
      • 2016-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-08
      • 2015-02-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多