Merge pull request #993 from pagameba/deviceorientation-ios

Detect iOS compass heading
This commit is contained in:
Frédéric Junod
2013-09-09 05:57:34 -07:00
9 changed files with 49 additions and 23 deletions

View File

@@ -122,6 +122,11 @@ ol.DeviceOrientation.prototype.orientationChange_ = function(browserEvent) {
// event.absolute is undefined in iOS.
if (goog.isBoolean(event.absolute) && event.absolute) {
this.set(ol.DeviceOrientationProperty.HEADING, alpha);
} else if (goog.isDefAndNotNull(event.webkitCompassHeading) &&
goog.isDefAndNotNull(event.webkitCompassAccuracy) &&
event.webkitCompassAccuracy != -1) {
var heading = goog.math.toRadians(event.webkitCompassHeading);
this.set(ol.DeviceOrientationProperty.HEADING, heading);
}
}
if (goog.isDefAndNotNull(event.beta)) {