Wikitude SDK API Reference

API Docs for: 8.4.0
Show:

GeoLocation Class

Extends Location
Module: AR

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.

Example:
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 Number

    The latitude of the location, in decimal degrees.

  • longitude Number

    The longitude of the location, in decimal degrees.

  • altitude (defaults to AR.CONST.UNKNOWN_ALTITUDE) Number optional

    The altitude of the location, in meters.

  • options Object optional

    Setup-Parameters to customize additional object properties.

    Accepted options-properties are

Methods

destroy

()

Inherited from ARchitectObject

Destroys the object.

distanceTo

(
  • location
)
Number

Inherited from Location

Returns the shortest distance ("as the crow flies") to the Location passed as an argument, ignoring any altitude property.

Example:
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 Location

    The Location the distance should be calculated for.

Returns:

Number:

The numeric distance in meters.

distanceToUser

() Number

Inherited from Location

Returns the shortest distance ("as the crow flies") to the current location of the user, ignoring any altitude property.

If the current position of the user cannot be determined, undefined will be returned.

Returns:

Number:

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

destroyed

Boolean

Inherited from ARchitectObject

Indicates if the object has already been destroyed.

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: