Change Base TileLayer in leaflet.dc.js

30 views
Skip to first unread message

David Saeger

unread,
Nov 11, 2016, 5:40:49 PM11/11/16
to dc-js user group
Anybody know how to change the base tile layer in leaflet.dc.js? The default OSM tilelayer is OK but there are other free tilesets that would work better in my project. 

Gordon Woodhull

unread,
Nov 12, 2016, 12:14:15 PM11/12/16
to dc.js user group
Hi David,

I agree, the default tiles are sort of meh, and I've been wondering how to get better ones.

Looks like you can use the .tiles() method to change the tile constructor. The default uses the tile source URL https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png but you just create a function which specifies another one.

Default function

var _tiles=function(map) {
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
};

https://github.com/dc-js/dc.leaflet.js/blob/master/src/leafletBase.js#L27-L31

Cheers,
Gordon

>
> On Nov 11, 2016, at 5:40 PM, David Saeger <saege...@gmail.com> wrote:
>
> Anybody know how to change the base tile layer in leaflet.dc.js? The default OSM tilelayer is OK but there are other free tilesets that would work better in my project.
>
> --
> You received this message because you are subscribed to the Google Groups "dc-js user group" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to dc-js-user-gro...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/dc-js-user-group/50b7ad3c-3bfd-4aa1-a850-70cb2a938dbc%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages