leafletmapbox

how to change url titleLayer mapbox


I need to change my url because I want modify my view map, but I don´t know how I change this url.

I want modify this:

L.tileLayer('https://{s}.tiles.mapbox.com/v4/mysaqygi.m8jo7i0g/{z}/{x}/{y}.png'

I use mapbox, but I don´t know how to change this url when I create my map. where do I change this?

I use leaflet to programming the visualization map


Solution

  • You can assign to variable like:

    var url1 = 'https://{s}.tiles.mapbox.com/v4/mysaqygi.m8jo7i0g/{z}/{x}/{y}.png';
    var tileLayer = L.tileLayer(url1,{});
    

    and then

    tileLayer.setUrl(url2);
    

    http://leafletjs.com/reference.html#tilelayer-seturl

    You can see here a demo of leaflet basemaps.