全球地图消失

时间:2015-11-30 15:58:41

标签: javascript leaflet openstreetmap

我将OpenStreetMap与Leaflet.js一起使用。

我有一张带有室内照片的地图。问题是当我放大,街道消失。你知道什么可以解决这个问题吗?技巧或提示!

enter image description here

enter image description here

修改

// Load the Map
this.map_ = L.map($(selector)[0], {
    center: [
      48.8459382,
      2.2863024,
    ],

    maxZoom: 24,
    zoom: 20,
});

1 个答案:

答案 0 :(得分:5)

我猜您在高数字时使用了map.options.maxZoom让用户缩放以查看室内图片的详细信息。

但是,OSM图块在缩放级别19之后不可用,因此服务器返回404错误,并且您的图块将被错误图块替换(如果未指定,则仅替换为灰色图块)。

在这种情况下,你只需要在 Tile Layer 上使用这两个选项(一起)告诉Leaflet重新使用较低缩放的图块并展开它们:

  • maxNativeZoom设置为19。
  • maxZoom设置为您需要的任何内容,如果指定则等于map.options.maxZoom
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    maxNativeZoom: 19, // OSM max available zoom is at 19.
    maxZoom: 22 // Match the map maxZoom, or leave map.options.maxZoom undefined.
}).addTo(map);

演示:http://jsfiddle.net/ve2huzxw/68/