3.6.6
All functions that are part of the IndoorAtlas Cordova plugin are scoped
under the IndoorAtlas
singleton object. For example the function
#initialize can be used in code as IndoorAtlas.initialize(...)
.
Most classes returned by the plugin, such as FloorPlan
(= IndoorAtlas.FloorPlan
) are not supposed to be constructed by the user
directly. The only exception is IndoorAtlas.Geofence.
Before you start, make sure you are familiar with the main phases of deploying IndoorAtlas technology. In particular, your physical location must be fingeprinted with the IndoorAtlas Map Creator 2 application before any of the below APIs will return meaningful values.
First, add IndoorAtlas plugin to the config.xml
file of your project
<plugin name="cordova-plugin-indooratlas" spec="git+https://github.com/IndoorAtlas/cordova-plugin.git" />
Then you can initialize in Cordova's "deviceready" callback or later, e.g.,
document.addEventListener('deviceready', () => {
// start positioning
IndoorAtlas.initialize({ apiKey: YOUR_IA_API_KEY })
.watchPosition(position => {
console.log(
"latitude: " + position.coords.latitude + ", " +
"longitude: " + position.coords.longitude + ", " +
"floor: " + position.coords.floor);
});
// auto-stop positioning after 60 seconds
setTimeout(() => IndoorAtlas.clearWatch(), 60000);
}, false);
All methods return the IndoorAtlas
singleton object to allow chaining
like in the above example.
Initializes IndoorAtlas location manager object with provided API key. Must be called before using other methods. Should be called in Cordova's deviceready callback or later.
object
:
returns
this
to allow chaining
IndoorAtlas.initialize({ apiKey: "3795eee9-efaf-47db-8347-316b6bb0c834" })
Starts IndoorAtlas positioning
(function (Position))
a callback that executes when the
position changes with an
IndoorAtlas.Position
object as the parameter.
(object)
positioning options (optional)
Name | Description |
---|---|
options.minChangeMeters number
|
(optional) Distance filter. If set, determines the minimum distance (in meters) the position has to change before the next position is reported. If not set, all changes in position are returned, which happens approximately once a second. |
options.minIntervalSeconds number
|
(optional) Time filter. The minimum amount of time measured in seconds that must be elapsed before an update event is generated. Setting this to 0 disables time based updates. Maximum update frequency is determined from values of distance filter and time filter. Update is generated when either of conditions specified by these filters are met. Default value is 2. |
options.positioningMode string
|
(optional) positioning mode.
One of:
HIGH_ACCURACY
,
LOW_POWER
or
CART
. Default is
HIGH_ACCURACY
|
object
:
returns
this
to allow chaining
IndoorAtlas.watchPosition(position => {
console.log(`
${position.coords.latitude}
${position.coords.longitude}
${position.coords.floor}`);
});
Stops IndoorAtlas positioning. Also clears any other watches.
object
:
returns
this
to allow chaining
IndoorAtlas.watchPosition(position => {
// do some positioning
});
// stop after 10 seconds
setTimeout(() => { IndoorAtlas.clearWatch(); }, 10000);
Start observing floor plan changes
(function (FloorPlan))
a callback that executes
when the floor plan changes.
null
if not currently on any floor plan.
object
:
returns
this
to allow chaining
IndoorAtlas.watchFloorPlan(floorPlan => {
if (floorPlan) {
console.log(`entered floor plan ${floorPlan.name}`);
}
});
Stop observing floor plan changes
object
:
returns
this
to allow chaining
Start observing venue changes
(function (Venue))
a callback that executes
when the venue changes.
null
if not currently near any venue.
object
:
returns
this
to allow chaining
Stop observing venue changes
object
:
returns
this
to allow chaining
Start observing status changes
(function (CurrentStatus))
a callback that executes
when the IndoorAtlas service status changes.
object
:
returns
this
to allow chaining
IndoorAtlas.onStatusChanged(console.log);
Stop observing status changes
object
:
returns
this
to allow chaining
Start observing for device orientation & heading changes
(function (Orientation))
a callback that executes
when the orientation of the device changes. Contains the heading and
other orientation angles.
object
:
returns
this
to allow chaining
IndoorAtlas.watchOrientation(orientation => {
console.log(`heading: ${orientation.trueHeading} degrees`);
});
Stop observing orientation changes
object
:
returns
this
to allow chaining
Request wayfinding from the current location of the user to the given coordinates. Also a #POI can be given as a destination.
Name | Description |
---|---|
destination.latitude number
|
Destination latitude in degrees |
destination.longitude number
|
Destination longitude in degrees |
destination.floor number
|
Destination floor number as defined in the mapping phase |
(function (Route))
a callback that executes
when the user's location is changed, gives the shortest route to the
given destination as an object
{ legs }
, where
legs
is a
list of
IndoorAtlas.RouteLeg
objects.
object
:
returns
this
to allow chaining
const destination = { latitude: 60.16, longitude: 24.95, floor: 2 };
IndoorAtlas.requestWayfindingUpdates(destination, route => {
console.log(`the route has ${route.legs.length} leg(s)`);
});
Stop wayfinding. Typically called after arriving to the destination (determined with #requestWayfindingUpdates) or if the user cancels the wayfinding session.
object
:
returns
this
to allow chaining
IndoorAtlas.removeWayfindingUpdates()
Request a single-shot wayfinding route. Also a #POI can be given as a source or destination.
Name | Description |
---|---|
from.latitude number
|
Starting location latitude in degrees |
from.longitude number
|
Starting location longitude in degrees |
from.floor number
|
Starting location floor number as defined in the mapping phase |
Name | Description |
---|---|
to.latitude number
|
Destination latitude in degrees |
to.longitude number
|
Destination longitude in degrees |
to.floor number
|
Destination floor number as defined in the mapping phase |
(function (Route))
a callback that executes
with the shortest route to the
given destination as an object
{ legs }
, where
legs
is a
list of
IndoorAtlas.RouteLeg
objects.
object
:
returns
this
to allow chaining
const from = { latitude: 60.16, longitude: 24.95, floor: 2 };
const to = { latitude: 60.161, longitude: 24.951, floor: 3 };
IndoorAtlas.requestWayfindingRoute(from, to, route => {
console.log(`the route has ${route.legs.length} leg(s)`);
});
Start monitoring for geofence events (entering or exiting geofences).
(geofenceCallback)
A callback which
is executed when a geofence is entered or exited.
object
:
Returns
this
to allow chaining
Stop monitoring enter/exit events for geofences.
object
:
Returns
this
to allow chaining
Add a geofence to be monitored for enter/exit.
(Geofence)
The geofence to be monitored.
object
:
Returns
this
to allow chaining
IndoorAtlas.addDynamicGeofence(new IndoorAtlas.Geofence({
id: '12345678-90ab-cdef-1234-567890abcdef',
name: 'My geofence',
floor: 1,
coordinates: [
[65.1234, 25.51234],
[65.1254, 25.51234],
[65.1254, 25.51334],
[65.1234, 25.51334],
[65.1234, 25.51234]
]
}));
Removes a dynamic geofence from being monitored.
any
:
Returns
this
to allow chaining
Provide a whole geofence object
var geofence = new IndoorAtlas.Geofence({ ... });
// ...
IndoorAtlas.removeDynamicGeofence(geofence);
Or just an geofence ID string
IndoorAtlas.removeDynamicGeofence('12345678-90ab-cdef-1234-567890abcdef');
Indicate current location to positioning service. This method can be used to pass a hint to the system e.g. when location is already known. This is completely optional and should only be used to shorten time it takes for the first fix. It is not recommended that this method is called with approximate locations with low or medium accuracy.
object
:
returns
this
to allow chaining
IndoorAtlas.setPosition({ latitude: 60.16, longitude: 24.95, floor: 2 });
Enable or disable indoor-outdoor detection. Disabled by default.
(boolean)
if
false
, enable automatic indoor-outdoor detection.
If
true
, disable automatic indoor-outdoor detection and keep positioning indoors.
object
:
returns
this
to allow chaining
IndoorAtlas.lockIndoors(false);
Disable automatic floor detection and lock the floor level to a given number
(number)
The floor number (integer) to lock the
positioning to. Use floor nubmers as defined in the mapping phase
object
:
returns
this
to allow chaining
IndoorAtlas.lockFloor(3);
Re-enable automatic floor detection after locking the floor with #lockFloor
object
:
returns
this
to allow chaining
IndoorAtlas.unlockFloor();
Returns the IndoorAtlas trace ID for this session in a callback.
(function (string))
A callback that returns the trace
ID string. Called only once on success.
object
:
returns
this
to allow chaining
IndoorAtlas.getTraceId(traceId => console.log(traceId));
Start observing beacon scans.
NOTE! To enable the callback, please contact IndoorAtlas support.
(function (iBeaconScanCallback))
a callback that executes
whenever IA SDK internally scans beacons.
object
:
returns
this
to allow chaining
IndoorAtlas.watchIBeacons((error, beacons) => {
if (error) {
console.log(`error scanning beacons: ${error.description} details: ${JSON.stringify(error.details)}`);
} else {
console.log(`scanned beacon count: ${beacons.length}`);
}
});
Stop observing beacon scans.
object
:
returns
this
to allow chaining
Start observing wifi scans. Only supported on Android.
NOTE! To enable the callback, please contact IndoorAtlas support.
(function (wifiScanCallback))
a callback that executes
whenever IA SDK internally scans wifis.
object
:
returns
this
to allow chaining
IndoorAtlas.watchWifis((error, wifis) => {
if (error) {
console.log(`error scanning wifis: ${error.description}`);
} else {
console.log(`scanned wifi count: ${wifis.length}`);
}
});
Stop observing wifi scans.
object
:
returns
this
to allow chaining
Callback function triggered on geofence events
Type: Function
Callback function triggered on beacon scans. Only one callback can be active at a time.
NOTE! To enable the callback, please contact IndoorAtlas support.
Type: Function
(RadioScanError)
or undefined if no error
Callback function triggered on wifi scans. Only one callback can be active at a time.
NOTE! To enable the callback, please contact IndoorAtlas support.
Type: Function
(RadioScanError)
or undefined if no error
Describes an indoor or outdoor location with coordinates, uncertainties and metadata such as IndoorAtlas floor plan and venue objects.
(any)
A set of geographic coordinates
Type: Coordinates
An IndoorAtlas.Coordinates
object is attached to a IndoorAtlas.Position
object that is available to callback functions in requests for the current
position. It contains a set of properties that describe the geographic
coordinates of a position.
(any)
A data object describing a floor plan. Can be obtained with #watchFloorPlan or as the Position#floorPlan member of the position returned by #watchPosition.
(any)
URL for bitmap resource
Type: string
"https://example.com/d346ea8a-3d1d-44a3-9c8b-3d4fa440a779.png"
The logical floor level of building as defined in the mapping phase
Type: number
2
The bearing of left side of floor plan in degrees East of true North
Type: number
143
Heigh of the floor plan image bitmap in pixels
Type: number
1024
Height of floor plan bitmap placed on the surface of Earth in meters
Type: number
25
Width of floor plan bitmap placed on the surface of Earth in meters
Type: number
50
Meters to pixels conversion factor Multiply distance in meters by this factor to get distance in pixels.
Type: number
20.48
Pixels to meters conversion factor. Multiply distance in pixels by this factor to get distance in meter
Type: number
0.05
WGS84 coordinates of the bottom left corner of the floor plan placed on the surface of Earth. Represented as array in lon, lat sequence
Type: array
[24.1234, 63.1234]
WGS84 coordinates of the center of the floor plan placed on the surface of Earth. Represented as array in lon, lat sequence
Type: array
[24.1234, 63.1234]
WGS84 coordinates of the top left corner of the floor plan placed on the surface of Earth. Represented as array in lon, lat sequence
Type: array
[24.1234, 63.1234]
WGS84 coordinates of the top rigth corner of the floor plan placed on the surface of Earth. Represented as array in lon, lat sequence
Type: array
[24.1234, 63.1234]
Converts given point to corresponding WGS coordinate. Inverse of #pointToCoordinate.
object
:
WGS84 coordinates
{ latitude, longitude }
.
floorPlan.pointToCoordinate(405, 185);
// returns { latitude: 63.1234, longitude: 24.1234 }
Converts given coordinate to corresponding point. Inverse of #coordinateToPoint
object
:
pixel coordinates
{ x, y }
.
floorPlan.pointToCoordinate(63.1234, 24.1234);
// returns { x: 405, y: 185 }
A data object describing a venue, also known as a building or location. Can be obtained with #watchVenue or as the Position#venue member of the object returned by #watchPosition.
(any)
POI, or Point Of Interest, is a special position inside a building
(any)
Convert a GeoJSON Point feature (see https://tools.ietf.org/html/rfc7946) to a POI.
(any)
POI
:
Returns a
POI
object.
IndoorAtlas service status obtained with #onStatusChanged.
(any)
(any)
Unrecoverable error, e.g., wrong API keys
Temporary network issue
Location service running normally
Permission issue, e.g., missing bluetooth or location permission
Describes the heading and orientation of the device. Obtained with #watchOrientation
(any)
Describes a wayfinding route consisting of IndoorAtlas.RoutingLeg
s.
Obtained with #requestWayfindingUpdates or #requestWayfindingRoute
(any)
Wayfinding route leg object
(any)
Routing point representing the beginning of this leg.
Type: RoutingPoint
Routing point representing the end of this leg.
Type: RoutingPoint
Wayfinding route point
(any)
A geofence describes a region of interest. Entering or exiting geofences will trigger SDK events caught by #watchGeofences. The geofences contained in a Venue are sent together with the venue (see #watchVenue and #watchPosition).
(any)
Convert a GeoJSON Polygon (see https://tools.ietf.org/html/rfc7946) to a geofence.
(any)
Geofence
:
Returns a
Geofence
object.
Unique identifier of the geofence
Type: string
'12345678-90ab-cdef-1234-567890abcdef'
A JavaScript object parsed from the free-form JSON payload
Convert geofence to GeoJSON representation (see https://tools.ietf.org/html/rfc7946).
object
:
The geofence as a GeoJSON Polygon feature.
IBeacon
(any)
Wifi
(any)
Error
(any)