Merge pull request #1865 from fredj/device-orientation
Make ol.DeviceOrientation dispatch change events
This commit is contained in:
@@ -24,12 +24,11 @@ var deviceOrientation = new ol.DeviceOrientation();
|
|||||||
var track = new ol.dom.Input(document.getElementById('track'));
|
var track = new ol.dom.Input(document.getElementById('track'));
|
||||||
track.bindTo('checked', deviceOrientation, 'tracking');
|
track.bindTo('checked', deviceOrientation, 'tracking');
|
||||||
|
|
||||||
deviceOrientation.on('propertychange', function(event) {
|
deviceOrientation.on('change', function(event) {
|
||||||
// event.key is the changed property name
|
$('#alpha').text(deviceOrientation.getAlpha() + ' [rad]');
|
||||||
var element = document.getElementById(event.key);
|
$('#beta').text(deviceOrientation.getBeta() + ' [rad]');
|
||||||
if (element) {
|
$('#gamma').text(deviceOrientation.getGamma() + ' [rad]');
|
||||||
element.innerHTML = deviceOrientation.get(event.key);
|
$('#heading').text(deviceOrientation.getHeading() + ' [rad]');
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// tilt the map
|
// tilt the map
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ ol.DeviceOrientation.prototype.orientationChange_ = function(browserEvent) {
|
|||||||
this.set(ol.DeviceOrientationProperty.GAMMA,
|
this.set(ol.DeviceOrientationProperty.GAMMA,
|
||||||
goog.math.toRadians(event.gamma));
|
goog.math.toRadians(event.gamma));
|
||||||
}
|
}
|
||||||
|
this.dispatchChangeEvent();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user