Skip to content
This repository has been archived by the owner on Dec 30, 2023. It is now read-only.

Change basemap before map rendered? #16

Open
ghost opened this issue Dec 8, 2015 · 1 comment
Open

Change basemap before map rendered? #16

ghost opened this issue Dec 8, 2015 · 1 comment

Comments

@ghost
Copy link

ghost commented Dec 8, 2015

Is it possible to change the basemap tiles before calling render on the map? Defining the base map tile layer under layers in the .mapOptions accessor doesn't seem to work and results in a blank map with no basemap or geojson data.

@jeanatpi
Copy link

Some years later but maybe can others too.
You can use .tiles method like this :

.tiles(function(map){
            L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
                attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
                maxZoom: 18,
                id: 'mapbox.streets',
                accessToken: '<AccessToken>'
            }).addTo(map);
        })

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant