OpenLayers 3 - Tiled Layer Template
Basic Fiddle for OL3 maps using tiled layers.
HTML
<script src="http://openlayers.org/en/master/build/ol.js"></script>
<link rel="stylesheet" href="http://openlayers.org/en/master/css/ol.css">
<div id="map"></div>
CSS
html, body, #map {
padding: 0;
margin: 0;
width: 100%;
height: 100%;
}
JavaScript
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM({
url: 'http://mt{0-3}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}',
attributions: [
new ol.Attribution({ html: '© Google' }),
new ol.Attribution({ html: '<a href="https://developers.google.com/maps/terms">Terms of Use.</a>' })
]
})
})
],
view: new ol.View({
center: ol.proj.transform(
[-110, 45], 'EPSG:4326', 'EPSG:3857'),
zoom: 3
})
});