TransWikia.com

Adding CartoDB basemap in OpenLayers 3?

Geographic Information Systems Asked by Alexis_A on February 23, 2021

I’m trying to add a CartoDB basemap to my OpenLayers map but I can’t get it to work. Here is the code I use to declare the basemap variable:

const carto = new ol.layer.Tile({ 
    source: new ol.source.XYZ({ 
        url:'http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png',
    })
});

Any idea where the problem comes from?

One Answer

const carto = new ol.layer.Tile({ 
    source: new ol.source.XYZ({ 
        url:'http://{1-4}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png',
    })
});

Correct answer by Alexis_A on February 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP