Skip to content

Commit

Permalink
Make sure Coordinates#heading follows the w3c specification.
Browse files Browse the repository at this point in the history
Heading (course) can have a negative value on iOS devices when the OS is not able to determine the current heading.
This is against the w3c specification. Which only allows null and a number value >= 0 and <= 360.

See the following links for further informations:

 * https://dev.w3.org/geo/api/spec-source.html#heading
 * https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/#//apple_ref/occ/instp/CLLocation/course
  • Loading branch information
Malte Legenhausen committed Jun 21, 2016
1 parent 9475224 commit a18093a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion www/Coordinates.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var Coordinates = function(lat, lng, alt, acc, head, vel, altacc) {
/**
* The direction the device is moving at the position.
*/
this.heading = (head !== undefined ? head : null);
this.heading = (typeof head === 'number' && head >= 0 && head <= 360 ? head : null);
/**
* The velocity with which the device is moving at the position.
*/
Expand Down

0 comments on commit a18093a

Please sign in to comment.