Global map tiles disappear past zoom level 19

前端 未结 1 1246
陌清茗
陌清茗 2021-01-14 18:57

I use OpenStreetMap with Leaflet.js.

I have a map with an indoor picture on it. The problem is when I zoom in, streets disapears. Do you know anything that can solve

相关标签:
1条回答
  • 2021-01-14 19:38

    I guess you have used map.options.maxZoom at a high number to let the user zoom to see your indoor image details.

    However, OSM tiles are not available past zoom level 19, so the server returns 404 errors and your tiles are replaced by the Error Tile (or just a grey tile if not specified).

    In that case, you would simply need to use these 2 options (together) on Tile Layer to tell Leaflet to re-use tiles from a lower zoom and to expand them:

    • maxNativeZoom set at 19.
    • maxZoom set at whatever you need, and equal to map.options.maxZoom if specified.
    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);
    

    Demo: http://jsfiddle.net/ve2huzxw/68/

    0 讨论(0)
提交回复
热议问题