From 4117a5df2d5ddcc4614dad2180c42318d5836113 Mon Sep 17 00:00:00 2001 From: Paul Spencer Date: Mon, 9 Sep 2013 08:05:37 -0400 Subject: [PATCH] check iOS compass calibration via webkitCompassAccuracy Ensure that webkitCompassAccuracy is not -1 as this indicates that the compass has not been calibrated and its values cannot be trusted. --- src/ol/deviceorientation.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ol/deviceorientation.js b/src/ol/deviceorientation.js index c10584091a..a9660d1119 100644 --- a/src/ol/deviceorientation.js +++ b/src/ol/deviceorientation.js @@ -122,7 +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)) { + } 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); }