Wayfinding Manager
WARNING: Please read carefully Using System Coordinates before continuing.
User position
The User location represents the User position on the map. By default it will take the one defined in the Calibration.
Change User position
There are 3 equivalent ways to change the User position depending on the coordinate system.
Change User position using GPS
adsumWebMap.wayfindingManager.setUserGpsPosition(
{ lat: 48.9019365, long: 2.3156367000000273, alt: 0 },
floorObjectOrNull // The floorObject on which the user is or null if he is on the Site
);
Change User position using Adsum Position
// Given position is relative to the floor/site object
adsumWebMap.wayfindingManager.setUserAdsumPosition(
{ x: 0, y: 0, z: 0 },
floorObjectOrNull // The floorObject on which the user is or null if he is on the Site
);
By default the position is relative to the floorObject (Local Adsum 3D System), you can use the third optional parameter to specify that the given position is absolute (World Adsum 3D System).
// Given position is absolute
adsumWebMap.wayfindingManager.setUserAdsumPosition(
{ x: 0, y: 0, z: 0 },
floorObjectOrNull, // The floorObject on which the user is or null if he is on the Site,
true
);
Change User position using UTM
adsumWebMap.wayfindingManager.setUserUtmPosition(
{ E: 449845.91, N: 5416780.35, alt: 0 },
floorObject // The floorObject on which the user is or null if he is on the Site
);
Note: the UTM uses a zone parameter, make sure the given zone match the one of the site.
Get Current User position
You can get the User position in UTM & GPS systems.
It returns null
if the User position isn't set yet.
// Returns {null|{floor: FloorObject|null, gps: {long: number, lat: number, alt: number }}}
adsumWebMap.wayfindingManager.getUserGpsPosition();
// Returns {null|{floor: FloorObject|null, utm: {N: number, E: number, alt: number }}}
adsumWebMap.wayfindingManager.getUserUtmPosition();
Observe the Change in User position
You can observe the change in User position by registering the WAYFINDING_EVENTS.user.position.didChanged
event.
adsumWebMap.wayfindingManager.addEventListener(
WAYFINDING_EVENTS.user.position.didChanged,
({ type, floor }) => {
// Do something
}
);
Note: The User position is not sent for performance reasons. You can then use the User position getter if you need them.
Adsum Location
Locations are pre-defined 3D positions, these locations are managed by the LocationRepository.
Get Adsum Location by id
The AdsumLocation#id match the AdsumClientApi.Place#id, which is useful when using the AdsumClientApi.
adsumWebMap.wayfindingManager.locationRepository.get(placeId);
Get Adsum Location by AdsumObject
An AdsumLocation can also be an AdsumObject3D, which can be useful to draw a path to a Space for example.
adsumWebMap.wayfindingManager.locationRepository.getByAdsumObject(adsumObject3D);
Adsum User Location
There is a special case, the AdsumLocation representing the User position. This is dynamic and updated each time the User position change.
adsumWebMap.wayfindingManager.locationRepository.userLocation;
Path
Path is used for wayfinding, we will see in the following chapter how to use it to find and display the best way.
Create a Path
A Path is defined by an origin and a destination, respectively identified by from
and to
properties.
You can create a Path from a location to another like this:
const path = new Path(fromLocation, toLocation);
Please note that if fromLocation or toLocation is null, then the User Location will be used.
Like this you can create a Path from the User location to another location by:
const path = new Path(null, toLocation);
The wheelchair access is managed by the third optional parameter, pmr
. By default it's false, so
to create a Path for wheelchair access you can do:
const path = new Path(fromLocation, toLocation, true);
Compute a Path
The Path computing will calculate the best way to go from a location to another considering the wheelchair access value.
await adsumWebMap.wayfindingManager.computePath(path);
Once computed, the Path is not displayed yet, but the object has been updated.
You can get the Path distance in meter using:
path.getDistance();
Note: We can only provide distance meter if the site has been georeferenced in the Studio Editor
PathSections
A PathSection is a part of Path, stick to a FloorObject or the SiteObject. You can retrieve them using Path.getPathSections
The PathSection has the following properties / methods:
from: AdsumLocation
: An AdsumLocation representing the origin of the PathSection (different from the parent Path#from except for the first one).to: AdsumLocation
: An AdsumLocation representing the destination of the PathSection (different from the parent Path#to except for the last one).ground: SiteObject|FloorObject
: The FloorObject or SiteObject on which this PathSection is defined.getDistance(): number
: The distance of that PathSection.
Note: You can have to consecutive PathSection on the same ground. For now it doesn't happen but will be introduce in next releases.
Draw a Path
To draw a Path, you will need to draw each PathSection one by one and eventually change the floor.
for(const pathSection of path.getPathSections()) {
const pathSectionFloor = pathSection.ground === adsumWebMap.objectManager.site ? null: pathSection.ground;
// Set the currentFloor
if (pathSectionFloor !== adsumWebMap.sceneManager.getCurrentFloor()) {
await adsumWebMap.sceneManager.setCurrentFloor(pathSectionFloor);
}
await adsumWebMap.wayfindingManager.drawPathSection(pathSection);
}
You can remove a drawn PathSection by doing:
adsumWebMap.wayfindingManager.removePathSection(pathSection);
Or remove all pathSections of a Path:
adsumWebMap.wayfindingManager.removePath(path);
Update a Path
Sometimes the Path has to be updated, for example when the User position change.
In that case, it's useful to know if the Path need to be recomputed and redrawn. In order to take a
decision you can use getUserDistanceFromPath
which will return the distance in meter:
adsumWebMap.wayfindingManager.getUserDistanceFromPath(path);
Or you can test for a specific PathSection:
adsumWebMap.wayfindingManager.getUserDistanceFromPathSection(pathSection);
So you may want to redraw the Path if the User position doesn't match anymore the Path drawn by doing:
adsumWebMap.wayfindingManager.addEventListener(
WAYFINDING_EVENTS.user.position.didChanged,
({ type, floor }) => {
if (adsumWebMap.wayfindingManager.getUserDistanceFromPath(path) > 5) {
await adsumWebMap.wayfindingManager.computePath(path);
for(const pathSection of path.getPathSections()) {
const pathSectionFloor = pathSection.ground === adsumWebMap.objectManager.site ? null: pathSection.ground;
// Set the currentFloor
if (pathSectionFloor !== adsumWebMap.sceneManager.getCurrentFloor()) {
await adsumWebMap.sceneManager.setCurrentFloor(pathSectionFloor);
}
await adsumWebMap.wayfindingManager.drawPathSection(pathSection);
}
}
}
);