Follow these steps to create a Stamen layer:
var stamenLayer = new ol.layer.Tile({
source: new ol.source.Stamen({
layer: 'toner'
})
}); 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
})
});
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.
Stamen source class refers to the beautiful tiles from Stamen. You can declare their source using the following content.
The constructor is ol.source.Stamen.
We will not review all properties, as most of them are configured by default. You can refer to the API docs at
http://openlayers.org/en/v3.0.0/apidoc/ol.source.Stamen.html.
The most important property to remember is the layer where you set the name of the available layer you want with:
new ol.source.Stamen({
layer: 'toner'
})
You will find all the available layers names derived from the three Stamen layers in the following table, their image type, and their default state. Be careful, particularly when you are using the .jpg images and the opaque property option together, the .jpg image format is unable to work with transparency. Refer to the following table for further information:
|
Name |
Extension |
opaque |
|---|---|---|
|
terrain |
|
true |
|
terrain-background |
|
true |
|
terrain-labels |
|
false |
|
terrain-lines |
|
false |
|
toner-background |
|
true |
|
toner |
|
true |
|
toner-hybrid |
|
false |
|
toner-labels |
|
false |
|
toner-lines |
|
false |
|
toner-lite |
|
true |
|
watercolor |
|
true |
Microsoft provides an interface to their mapping services as well. Their mapping service previously was referred to as Virtual Earth, but they have since rebranded it as Bing Maps. The official Microsoft documentation can be found at http://msdn.microsoft.com/en-us/library/dd877180.aspx.