4

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:

var 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?

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.