3.0.0
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(...)
.
The classes returned by the plugin, such as FloorPlan
(= IndoorAtlas.FloorPlan
) are not supposed to be constructed by the user
directly.
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)
distance filter 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. |
object
:
returns
this
to allow chaining
IndoorAtlas.watchPosition(position => {
console.log(`
${position.coords.latitude}
${position.coords.longitude}
${position.coords.floor}`);
});
Stops IndoorAtlas positioning. Other watches are not cleared by this opertation.
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
(object)
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()
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)
Name | Description |
---|---|
position.coordinates Coordinates
|
Like
IndoorAtlas.Coordinates
,
must have at least
latitude
and
longitude
members
|
object
:
returns
this
to allow chaining
IndoorAtlas.setPosition({ latitude: 60.16, longitude: 24.95, floor: 2 });
Disable or re-enable indoor-outdoor detection
(boolean)
if
true
keep positioning indoors and disable
automatic indoor-outdoor detection. If
false
, re-enable automatic
indoor-outdoor detection
object
:
returns
this
to allow chaining
IndoorAtlas.lockIndoors(true);
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));
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)
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
(any)
List of legs in this route
Type: Array<RoutingLeg>
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)