Class: Compass

Compass()

new Compass()

The compass class is a utility for creating a javascript compass with no external dependencies. You can create a compass that points north from your location or points towards a specified latitude and longitude coordinate. Regardless of where you turn the compass will point towards the specified direction.
Source:

Methods

calculateAngle(userLat, userLon, desiredLat, desiredLon)

Calculates the angle given a latitude and longitude position
Parameters:
Name Type Description
userLat number user latitude
userLon number user longitude
desiredLat number desired latitude
desiredLon number desired longitude
Source:

callCallback(promise, callback)

Helper function that allows calling a callback from an promise function
Parameters:
Name Type Description
promise promise
callback callback
Source:

confirmDialog(msg)

Promisifies the confirm dialog
Parameters:
Name Type Description
msg String
Source:

getBearing(origin, destination)

This is the angle between the location of an object, machine or destination and my heading.
Parameters:
Name Type Description
origin Object {lat, lng}
destination Object {lat, lng}
Source:

getBearingToDestination(origin, destination)

Get the bearings towards the destination
Parameters:
Name Type Description
origin object {lat, lng}
destination object {lat, lng}
Source:

getBearingToNorth(origin, north)

get the angle between your heading and north the default is true north vs. magnetic north
Parameters:
Name Type Description
origin object {lat, lng}
north object {lat, lng}
Source:

(async) getPosition()

get the position of the user
Source:

init(callback)

initialized the compass - returns a promise or can invoke a callback
Parameters:
Name Type Description
callback callback callback to be called after the .start() function is done
Source:

stopTracking()

Stops watching the user location
Source:

(async) watchPosition()

watches the geolocation of the user
Source:

Type Definitions

deviceOrientationHandler

Handles changes created by the device orientation changes assumes that the phone is in a portrait mode, with the display up towards the sky as if you were holding an actual compass
Source: