The automatic recognition of floor plans, locations (a.k.a. venues) and outdoor-indoor transitions (see prev section) are handled in the IndoorAtlas SDK with IARegion
events.
Obj C:
// Handling region enter events - (void)indoorLocationManager:(IALocationManager *)manager didEnterRegion:(IARegion *)region { switch (region.type) { case kIARegionTypeVenue: NSLog(@"Entered venue %@", region.identifier); break; case kIARegionTypeFloorPlan: NSLog(@"Entered floor plan %@", region.identifier); break; } } // Handling region exit events - (void)indoorLocationManager:(IALocationManager *)manager didExitRegion:(IARegion *)region { switch (region.type) { case kIARegionTypeVenue: NSLog(@"Exit venue %@", region.identifier); break; case kIARegionTypeFloorPlan: NSLog(@"Exit floor plan %@", region.identifier); break; } }
Swift:
// Handling region enter events func indoorLocationManager(_ manager: IALocationManager, didEnter region: IARegion) { switch region.type { case .iaRegionTypeVenue: print("Entered venue \(region.identifier)") case .iaRegionTypeFloorPlan: print("Entered floor plan \(region.identifier)") case .iaRegionTypeGeofence: print("Entered geofence \(region.identifier)") default: break } } // Handling region exit events func indoorLocationManager(_ manager: IALocationManager, didExitRegion region: IARegion) { switch region.type { case .iaRegionTypeVenue: print("Exit venue \(region.identifier)") case .iaRegionTypeFloorPlan: print("Exit floor plan \(region.identifier)") case .iaRegionTypeGeofence: print("Exit geofence \(region.identifier)") default: break } }
The IALocationManager delegate must be set before using these events.
Obj C:
self.locationManager.delegate = self;
Swift:
locationManager.delegate = self
Disabling automatic floor detection
Even though this is not recommended, you can substitute IndoorAtlas floor detection with your own by providing an explicit floor number.
Locking positioning can be done by using the new lockFloor method in IALocationManager. In addition to locking, method unlockFloor is provided so positioning can be unlocked from the specific floor.
Obj C:
// Lock position to floor number 3 IALocationManager *manager = [IALocationManager sharedInstance]; [manager lockFloor:3]; // Unlock positioning so floor level is detected automatically [manager unlockFloor];