Search code examples
leaflet

How to add satellite view in leaflet?


In my web application, I'm using leaflet and I want to change layer of leaflet to satellite view and other map views using layer switch. How can I perform this.Please help!


Solution

  • You need to be a little more specific with your questioning...that said, something like this might help.

    var osm = L.tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"),
        mqi = L.tileLayer("http://{s}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png", {subdomains: ['otile1','otile2','otile3','otile4']});
    
    var baseMaps = {
        "OpenStreetMap": osm,
        "MapQuestImagery": mqi
    };
    
    var overlays =  {//add any overlays here
    
        };
    
    L.control.layers(baseMaps,overlays, {position: 'bottomleft'}).addTo(map);