Working with Events
Overview
Let's 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.
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.
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.
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.
Last updated