Follow these steps to create a Stamen layer:
We can access the Stamen layer from the outside of the box. This will be pretty simple. First, we just need to create a layer object:
var stamenLayer = new ol.layer.Tile({ source: new ol.source.Stamen({ layer: 'toner' }) });
Then, we just construct the map directly, adding the view and the layer already configured at startup:
var map = new ol.Map({ layers: [stamenLayer], target: 'map', view: new ol.View({ center: ol.proj.transform([2.35239, 48.858391], 'EPSG:4326', 'EPSG:3857'), zoom: 12 }) });
You should see something like the following screenshot:
The map we've just created shows a black and white Stamen layer. You can look at other available layers for Stamen, the list is available just after the Stamen Layers' properties below.