Automatic floor plan detection is handled with IARegion events as described in the floor detection chapter. For your convenience, IndoorAtlas SDK also provides an API for fetching the floor plan images that you have stored in our cloud in the mapping phase.



Note!
If you use an indoor map provider, you probably want to skip this and use their API for displaying the floor plan instead.


To display a location on the floor plan, we are going to download a floor plan image from the service and add it to the map as an overlay view.



IARegion class has two properties relating to the new functionality: floorplan and venue. The properties will return the metadata relating to either the floor plan or venue, depending which one the IARegion corresponds to (as previously, type can be checked with type property). We have also added new class IAVenue which represents the metadata for venue.


1. Implement the didEnterRegion listener


Objective C


- (void)indoorLocationManager:(IALocationManager *)manager didEnterRegion:(IARegion *)region
{
    if (region.type != kIARegionTypeFloorPlan)
        return;

    [self fetchImage:region.floorplan];
}


2. Fetch the image bitmap 


(void)fetchImage:(IAFloorPlan *)floorPlan
{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
                   ^{
                       NSData *imageData = [NSData dataWithContentsOfURL:[floorPlan imageUrl]];
                       dispatch_sync(dispatch_get_main_queue(), ^{
                           fpImage = [UIImage imageWithData:imageData];
                       });
                   });
}