From ff1a9d420db1059163f0b0510de8584df0da1e81 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 28 Apr 2014 14:35:37 +0200 Subject: [PATCH] Add an extent constraint to the device-orientation example --- examples/device-orientation.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/device-orientation.js b/examples/device-orientation.js index fb64f82f2f..a8786b8252 100644 --- a/examples/device-orientation.js +++ b/examples/device-orientation.js @@ -3,10 +3,14 @@ goog.require('ol.Map'); goog.require('ol.View2D'); goog.require('ol.dom.Input'); goog.require('ol.layer.Tile'); +goog.require('ol.proj'); goog.require('ol.source.OSM'); +var projection = ol.proj.get('EPSG:3857'); var view = new ol.View2D({ center: [0, 0], + projection: projection, + extent: projection.getExtent(), zoom: 2 }); var map = new ol.Map({ @@ -41,5 +45,5 @@ deviceOrientation.on(['change:beta', 'change:gamma'], function(event) { center[0] -= resolution * gamma * 25; center[1] += resolution * beta * 25; - view.setCenter(center); + view.setCenter(view.constrainCenter(center)); });