diff --git a/examples/device-orientation.js b/examples/device-orientation.js index 51901b6e8b..fb64f82f2f 100644 --- a/examples/device-orientation.js +++ b/examples/device-orientation.js @@ -24,12 +24,11 @@ var deviceOrientation = new ol.DeviceOrientation(); var track = new ol.dom.Input(document.getElementById('track')); track.bindTo('checked', deviceOrientation, 'tracking'); -deviceOrientation.on('propertychange', function(event) { - // event.key is the changed property name - var element = document.getElementById(event.key); - if (element) { - element.innerHTML = deviceOrientation.get(event.key); - } +deviceOrientation.on('change', function(event) { + $('#alpha').text(deviceOrientation.getAlpha() + ' [rad]'); + $('#beta').text(deviceOrientation.getBeta() + ' [rad]'); + $('#gamma').text(deviceOrientation.getGamma() + ' [rad]'); + $('#heading').text(deviceOrientation.getHeading() + ' [rad]'); }); // tilt the map diff --git a/src/ol/deviceorientation.js b/src/ol/deviceorientation.js index aab556ebef..b7d87fe9b9 100644 --- a/src/ol/deviceorientation.js +++ b/src/ol/deviceorientation.js @@ -140,6 +140,7 @@ ol.DeviceOrientation.prototype.orientationChange_ = function(browserEvent) { this.set(ol.DeviceOrientationProperty.GAMMA, goog.math.toRadians(event.gamma)); } + this.dispatchChangeEvent(); };