Working with Events

Last updated:

  1. Developing on the new Arm-based Apple Silicon (M1) Macs requires building and running on a physical iOS device or using an iOS simulator running iOS 13.7, e.g. iPhone 11. This is a temporary limitation in Google Maps SDK for iOS, and as such also a limitation in MapsIndoors, due to the dependency to Google Maps.
  2. Note: Due to a bug in CocoaPods it is necessary to include the post_install hook in your Podfile described in the PodFile post_install wiki.

The MapControl delegate can inform you when the various data from the MapsIndoors services are loaded through it's MPMapControlDelegate so you should set the delegate, in most of the cases with the current UIViewController:

myMapControl.delegate = self

Implement the onMapDataReady method :

class ViewController: UIViewController, MPMapControlDelegate

Then implementing the methods below :

func onMapDataReady(){



In this, we will take a look at the events that MapsIndoors offers and how to utilize them.

Events are actions or occurrences that happen in the system you are programming, which the system tells you about so you can respond to them in some way if desired. -- MDN web docs

For example, if the user clicks on a Location on the map, then you can react to that action by presenting the user with additional info about the Location.

A code example is shown in the JSFiddle below, but will be run through bit by bit in this guide.

Ready Event

The ready event will be fired when MapsIndoors is done initializing and is ready to interact.

mapsIndoors.addListener('ready', (e) => {
log(`MapsIndoors: Ready`);

Building Changed Event

The building_changed event will be fired when the map is moved around and a new Building comes in focus.

This is also related to the Floor Selector, which will update its view to show the Floors of the current Building.

The event handler is called with a building object representing the building in focus.

mapsIndoors.addListener('building_changed', (e) => {
log(`Building changed: ${}`);

Floor Changed Event

The floor_changed event will be fired when the Floor is changed; either by clicking the Floor Selector or by calling setFloor() on the MapsIndoors instance.

The event handler is called with the Floor Index of the current Floor.

mapsIndoors.addListener('floor_changed', (e) => {
log(`Floor changed: ${e}`);

Click Event

The click event will fire when the user clicks on a Location on the map.

The event handler is called with a location object representing the Location clicked.

mapsIndoors.addListener('click', (location) => {
log(`Clicked: ${}`);