[GIS] Leaflet – Can I use a different background tile provider depending on zoom level

leaflettiles

This may look strange, but I cannot made up my mind between providers of satellite tiles for Leaflet. ESRI sattelite looks beautiful, but cannot reach the zoom level I need. HERE is not nice on low zoom levels, but goes as deep as I want.

Can I use ESRI for low zooms and HERE for high ones?

How do I do this?

Do you think it is wise?

Best Answer

It's fine to use different tile sources for different zoom levels, just set the min and max zoom on each layer, and don't have the zoom ranges overlap.

    var map = L.map('map').setView([45, -110], 10);
    L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
        attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
        minZoom: 0,
        maxZoom: 10
    }).addTo(map);
    L.tileLayer('http://tile.stamen.com/watercolor/{z}/{x}/{y}.jpg', {
        attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
        minZoom: 11,
        maxZoom: 16
    }).addTo(map);
Related Question