To achieve your task, combine our knowledge and just follow these instructions:
<!doctype html>
<html lang="en">
<head>
<title>Playing with various sources and layers </title>
<link rel="stylesheet" href="../assets/ol3/css/ol.css" type="text/css" />
<link rel="stylesheet" href="../assets/css/samples.css" type="text/css" />
</head>
<body>
<div id="map" class="map"></div>
<script src="../assets/ol3/ol.js" ></script>
<script>
</script>
</body>
</html><script> tag. We add together two Bing Maps layers and add to them a name using set . We will reuse this parameter later:var bingMapsAerial = new ol.layer.Tile({
source: new ol.source.BingMaps({
key: 'AlQLZ0-5yk301_ESrmNLma3LYxEKNSg7w-e_knuRfyYFtld-UFvXVs38NOulku3Q',
imagerySet: 'Aerial'
})
});
bingMapsAerial.set(
'name', 'Bings Maps Aerial'
);
var bingMapsRoad = new ol.layer.Layer({
source: new ol.source.BingMaps({
key: 'AlQLZ0-5yk301_ESrmNLma3LYxEKNSg7w-e_knuRfyYFtld-UFvXVs38NOulku3Q',
imagerySet: 'Road',
culture: 'fr-FR'
})
});
bingMapsRoad.set(
'name', 'Bings Maps Road'
);var mapQuestAerial = new ol.layer.Tile({
source: new ol.source.MapQuest({layer: 'sat'})
});
mapQuestAerial.set('name', 'MapQuest Open Aerial');topp:states layer from the URL http://demo.boundlessgeo.com/geoserver/wms and various label layers back from the WMS server. We'll also set the opacity to 0.6, that is 60 percent opaque. The projection is not specified: it comes from the view and we know that the remote layer service available has the right projection (using getCapabilities). Go ahead and create the WMS layer and add again a name:var simpleWMS = new ol.layer.Image({
opacity: 0.6,
source: new ol.source.ImageWMS({
url: 'http://demo.boundlessgeo.com/geoserver/wms',
params: {
'LAYERS': 'topp:states'
},
extent: [-13884991, -7455066, 2870341, 6338219]
})
});
simpleWMS.set('name', 'USA layer from Geoserver WMS demo');var layers = [bingMapsAerial, bingMapsRoad, mapQuestAerial, simpleWMS];
map object, add into the layers object and the view too.var map = new ol.Map({
layers: layers,
target: 'map',
view: new ol.View({
center: ol.proj.transform([-90, 40], 'EPSG:4326', 'EPSG:3857'),
zoom: 3
})
});Now, we'll create a function with a special purpose: creating an HTML label tag and also and HTML input checkbox. It will have three parameters: one for the name, one to create an id for the HTML input, and the planned place where we want to create this checkbox:
function generate_checkbox(id_checkbox, label_name, html_element) {
var checkbox = document.createElement('input');
checkbox.type = "checkbox";
checkbox.id = id_checkbox;
var label = document.createElement('label');
label.htmlFor = id_checkbox;
label.appendChild(document.createTextNode(label_name));
html_element.appendChild(checkbox);
html_element.appendChild(label);
}ol.dom.Input and bindTo but don't bother about it at the moment:for (var i = layers.length - 1; i >= 0; i--) {
var id = layers[i].get('id');
var name = layers[i].get('name');
generate_checkbox('layer_id_' + i, name, document.body);
var visible = new ol.dom.Input(document.getElementById('layer_id_' + i));
visible.bindTo('checked', layers[i], 'visible');
};We just created a map using different tiles' layers with a WMS overlay. We also create, as a bonus, a simple but dynamic layer switcher. All the layers use the map's projection, EPSG:3857, and line up with the lower aerial Bing Maps.

We choose, for learning purposes, to only use the OpenLayers library code to manage layers display but an external component to the library is also available for this goal at https://github.com/walkermatt/ol3-layerswitcher. Try it on your own and enjoy! It will be a good opportunity to learn more about ol.layer.Group, we didn't really review until now.
After revising, it's time to see another source to display the image: the ol.source.MapGuide source.
We didn't review this server, although an open source version of this server is available at http://mapguide.osgeo.org, when we saw the various servers available to provide images for the OpenLayers 3 library. We chose to not cover it in detail, because this solution is not mainstream and beginners will not be able to dive deeper in to this complex solution.
You just need to understand that this image source is unusual and is mostly used by people coming from the CAD (Computer-aided design) world because this software was released as open source by AutoDesk, the leading company for 2D/3D drawing software.