Add an extent constraint to the device-orientation example
This commit is contained in:
@@ -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));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user