Add ol.DeviceOrientation

This commit is contained in:
Frederic Junod
2013-02-04 09:59:38 +01:00
parent 7cd5266d39
commit 448e300a03
11 changed files with 292 additions and 5 deletions

View File

@@ -0,0 +1,29 @@
goog.require('ol.DeviceOrientation');
goog.require('ol.Map');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
goog.require('ol.layer.TileLayer');
goog.require('ol.source.OSM');
var view = new ol.View2D({
center: [0, 0],
zoom: 2
});
var map = new ol.Map({
layers: [
new ol.layer.TileLayer({
source: new ol.source.OSM()
})
],
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
view: view
});
var deviceOrientation = new ol.DeviceOrientation();
deviceOrientation.on('changed', function() {
document.getElementById('alpha').innerHTML = deviceOrientation.getAlpha();
document.getElementById('beta').innerHTML = deviceOrientation.getBeta();
document.getElementById('gamma').innerHTML = deviceOrientation.getGamma();
});