OpenLayers 3 - Tiled Layer Template
Basic Fiddle for OL3 maps using tiled layers.
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.7.0/ol.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.7.0/ol.min.css">
<button>Pan Map</button>
<div id="status"></div>
<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.MapQuest({layer: 'osm'})
})
],
view: new ol.View({
center: ol.proj.transform(
[-110, 45], 'EPSG:4326', 'EPSG:3857'),
zoom: 3
})
});
$('button').on('click', function(){
var pan = ol.animation.pan({
duration: 2000,
source: map.getView().getCenter()
});
map.getView().setCenter(ol.proj.fromLonLat([-0.12755, 51.507222]));
});
map.on("movestart",function(){
$("#status").append("THIS WILL NEVER SHOW.");
})
map.on("moveend",function(){
$("#status").append("move end...");
});