dc-js / dc.leaflet.js

DC charts using Leaflet maps
Apache License 2.0
52 stars 24 forks source link

Change basemap before map rendered? #16

Open ghost opened 8 years ago

ghost commented 8 years ago

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 commented 5 years ago

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);
        })