From 69872c99d27cc063dc88bc2a9ead3f64359778a2 Mon Sep 17 00:00:00 2001 From: Paul Spencer Date: Sat, 7 Sep 2013 21:48:49 -0400 Subject: [PATCH] Detect iOS compass heading iOS webkit does not provide an absolute alpha, instead it provides webkitCompassHeading. --- src/ol/deviceorientation.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ol/deviceorientation.js b/src/ol/deviceorientation.js index 3b86d5bba4..c10584091a 100644 --- a/src/ol/deviceorientation.js +++ b/src/ol/deviceorientation.js @@ -122,6 +122,9 @@ 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)) { + var heading = goog.math.toRadians(event.webkitCompassHeading); + this.set(ol.DeviceOrientationProperty.HEADING, heading); } } if (goog.isDefAndNotNull(event.beta)) {