GeoLocation Class
Every instance of GeoLocation represents a location in the
earth's three-dimensional space.
A GeoLocation
consists of latitude and longitude and an optional altitude
property. If the altitude is not specified, the altitude will be
set to AR.CONST.UNKNOWN_ALTITUDE. In the application, the
altitude of the location will implicitly set to the user's
current altitude.
The Coordinate system used is WGS
84 (see the
Wikipedia article for details).
Typically,
GeoLocations will be created and then used for the creation of
GeoObjects and ActionRanges.
var location1 = new AR.GeoLocation(47.77317, 13.069929); var altitude = location1.altitude; //altitude = -32768 var location2 = new AR.GeoLocation(47.77317, 13.069929, 320.); altitude = location2.altitude; //alt = 320 var object1 = new AR.GeoObject(location1); var object2 = new AR.GeoObject(location2);
Constructor
GeoLocation
-
latitude
-
longitude
-
altitude
-
options
Parameters:
-
latitude
NumberThe latitude of the location, in decimal degrees.
-
longitude
NumberThe longitude of the location, in decimal degrees.
-
altitude
(defaults toAR.CONST.UNKNOWN_ALTITUDE
) Number optionalThe altitude of the location, in meters.
-
options
Object optionalSetup-Parameters to customize additional object properties.
Accepted options-properties are-
onError
Function optional
-
Item Index
Methods
Events
Methods
destroy
()
Destroys the object.
distanceTo
-
location
Returns the shortest distance ("as the crow flies")
to the Location passed as an argument, ignoring any altitude property.
var location1 = new AR.GeoLocation(47.77317, 13.069929); var location2 = new AR.GeoLocation(47.77317, 13.069929, 320.); var location3 = new AR.GeoLocation(47.77317, 14.069929, 640.); var dist = location2.distanceTo(location1); //dist = 0. dist = location2.distanceTo(location3); //dist = 74730.
Parameters:
-
location
LocationThe Location the distance should be calculated for.
Returns:
The numeric distance in meters.
Properties
altitude
Number
The altitude of the location, in meters. Values must be numeric values, otherwise, an Exception will be thrown.
Default: AR.CONST.UNKNOWN_ALTITUDE
latitude
Number
The latitude of the location, in decimal degrees. Values must be numeric values in range [-90, 90], otherwise, an Exception will be thrown.
longitude
Number
The longitude of the location, in decimal degrees. Values must be numeric values in range [-180, 180], otherwise, an Exception will be thrown.
Events
onError
The trigger will fire when the GeoLocation could not be loaded.
The trigger is null by default, and will thus result in no action executed when the trigger fires. A developer can add custom functionality by assigning a custom function to onError.
Event Payload:
-
error
Stringmessage