Setup Wayfinding
Tip: Runnable example with wayfinding is available in the iOS SDK examples (Objective-C) and iOS SDK examples (Swift) (see Map View example).
To use the IndoorAtlas Wayfinding in your project, you need to create a wayfinding graph using the IA wayfinding editor (see Wayfinding graph) and setup the positioning SDK.
Using Wayfinding
To begin, first setup your IALocationManagerDelegate as instructed in the getting location updates with iOS guide.
Next create a didUpdateRoute listener that you use to implement what happens in your application when the route is updated (e.g. plot the updated route over your floor plan image).
Objective-C:
- (void)indoorLocationManager:(IALocationManager *)manager didUpdateRoute:(IARoute *)route { // Put your actions here }
Swift:
func indoorLocationManager(_ manager: IALocationManager, didUpdate route: IARoute) { // Put your actions here }
Next start monitoring for wayfinding updates by giving the coordinates and floor number of the desired destination to the IALocationManager instance.
Objective-C:
// Set the destination coordinates to 60.0 (lat), 24.0 (lng) and floor 1 IALocationManager *locationManager = [IALocationManager sharedInstance]; IAWayfindingRequest *request = [[IAWayfindingRequest alloc] init]; request.coordinate = CLLocationCoordinate2DMake(60.0, 24.0); request.floor = 1; [locationManager startMonitoringForWayfinding:request];
Swift:
// Set the destination coordinates to 60.0 (lat), 24.0 (lng) and floor 1 let locationManager = IALocationManager.sharedInstance() let request = IAWayfindingRequest() request.coordinate = CLLocationCoordinate2DMake(60.0, 24.0) request.floor = 1 locationManager.startMonitoring(forWayfinding: request)
This starts the IA wayfinding which will update the route each time the user location is updated. Wayfinding can be stopped by calling:
Objective-C:
IALocationManager *locationManager = [IALocationManager sharedInstance]; [locationManager stopMonitoringForWayfinding];
Swift:
locationManager.stopMonitoringForWayfinding()
IARoute is a list of legs where each leg is a straight line segment. The legs also contain pointers to the original nodes and edges of the wayfinding graph, to allow linking to possibly relevant metadata, but using that information is often not mandatory. One IARouteLeg in the route list contains the following variables:
IARoutePoint *begin; IARoutePoint *end; double length; double direction; NSNumber *edgeIndex;
where the IARoutePoints contain the following variables:
CLLocationCoordinate2D coordinate; int floor; NSNumber *nodeIndex;
The variables edgeIndex
and nodeIndex
point to edges and nodes in the original graph. Note that the index variables can be null for the first and last legs of the route, that present the final connections between the graph and arbitrary off-graph locations.
The begin
node of the first leg is always the starting location and the end
node of the last leg is the destination. The returned route can also be empty if no possible route was found. This can happen if the given destination or start location floor
number does not exist in the wayfinding graph.