Pointr Web SDK Events¶
This guide offers detailed information on events triggered by the Pointr Web SDK, covering UI components like MapView, LevelSelectorView, and ZoomSelectorView. Developers can manage interactions such as map clicks, zoom actions, and POI selections. Each section lists event types, triggers, and relevant data, with examples on managing event lifecycles for dynamic application responses. This resource is valuable for developers customizing or implementing interactive features using Pointr’s SDK in kiosks, websites, or wayfinding systems.
- MapWidget Events
- MapView Events
- LevelSelectorView Events
- ZoomSelectorView Events
- SearchView Events
- PoiDetailsView Events
- NavigationView Events
- PoiCardsView Events
- LanguageSelectorView Events
- RatingView Events
- InfoView Events
- LoadingView Events
- WelcomeView Events
- Listener Pattern
Sample usage of events:¶
const uiController = pointrWeb.getUiController();
const mapViewController = uiController.getMapViewController();
const mapView = mapViewController.getView();
const events = mapView.events;
const callback1 = () => {
console.log("Map shown!");
};
mapView.on(events.viewShown, callback1);
// event with data
const callback2 = (newLevel) => {
console.log("Map level changed to ", newLevel);
};
mapView.on(events.levelChanged, callback2);
Sample usage of detaching events:¶
const uiController = pointrWeb.getUiController();
const mapViewController = uiController.getMapViewController();
const mapView = mapViewController.getView();
const events = mapView.events;
const callback = (newLevel) => {
console.log("***Map level changed to ", newLevel);
};
mapView.on(events.levelChanged, callback);
// Event will be removed after 10 seconds
setTimeout(() => {
mapView.off(events.levelChanged, callback);
}, 10 * 1000);
MapWidget Events¶
const events = pointrWeb.events;
MapWidget Events | Trigger conditions | Additional data |
---|---|---|
events.dataLoaded | When all data needed for SDK gets loaded successfully. | None. |
MapView Events¶
Available events for the MapView component can be accessed as follows:
const events = pointrWeb
.getUiController()
.getMapViewController()
.getView().events;
MapView Events | Trigger conditions | Additional data |
---|---|---|
events.viewShown | When the map view is shown. | None. |
events.viewHidden | When the map view is hidden. | None. |
events.levelChanged | When the map level is changed. | (Number) new levelIndex |
events.zoom | When the map zoom level is changed. It fires instantly when the zoom level is changed. | (Number) new zoom level |
events.zoomChanged | When the map zoom level is changed. It fires after zoom changes are completed. | (Number) new zoom level |
events.mapIdle | When the map component completes all ongoing tasks (loading animations, camera changing activity, tile loading) and goes into an idle state. | None. |
events.mapClicked | When the map is clicked. | Array of geojson features that are clicked. If no feature available, it will be an empty array. |
events.mapLongClicked | When the map is long clicked. (Available after 8.1.0) | (Object) {lngLat: {lng: Number, lat: Number}, point: {x: Number, y: Number} } |
events.infoClicked | When the info button is clicked. (Available after 8.14) | None. |
events.locationMarked | When a location is marked on the map after long click. (Available after 8.1.0) | (Object) Feature Object of the marked location. |
events.poiClicked | When a Point of Interest (POI) is clicked. | (Object) Poi Object of the clicked POI. |
events.poiHighlighted | When a Point of Interest (POI) is highlighted. | (Object) Poi Object of the highlighted POI. |
events.poiUnhighlighted | When a Point of Interest (POI) is unhighlighted. | None. |
events.mapReady | When the map is ready to be used and completed its initialization. | None. |
events.mapMoveStart | When the map starts moving. | None. |
events.mapMoveEnd | When the map stops moving. | None. |
events.currentSiteChanged | When the current site is changed. | (Object) {oldSite: Site Object, newSite: Site Object} |
events.currentBuildingChanged | When the current building is changed. | (Object) {oldCurrentBuilding: Building Object, newCurrentBuilding: Building Object} |
events.routesShown | When the routes are shown on the map. | None. |
events.exitClicked | When the site/building exit button is clicked. | None. |
LevelSelectorView Events¶
Available events for the LevelSelectorView component can be accessed as follows:
const events = pointrWeb
.getUiController()
.getLevelSelectorViewController()
.getView().events;
LevelSelectorView Events | Trigger conditions | Additional data |
---|---|---|
events.viewShown | When the level selector view is shown. | None. |
events.viewHidden | When the level selector view is hidden. | None. |
events.levelSelected | When a level is selected. | (Number) index of the selected level on the selector |
ZoomSelectorView Events¶
Available events for the ZoomSelectorView component can be accessed as follows:
const events = pointrWeb
.getUiController()
.getZoomSelectorViewController()
.getView().events;
ZoomSelectorView Events | Trigger conditions | Additional data |
---|---|---|
events.viewShown | When the zoom selector view is shown. | None. |
events.viewHidden | When the zoom selector view is hidden. | None. |
events.zoomIn | When the zoom in button is clicked. | None. |
events.zoomOut | When the zoom out button is clicked. | None. |
¶
Available events for the SearchView component can be accessed as follows:
const events = pointrWeb
.getUiController()
.getSearchViewController()
.getView().events;
SearchView Events | Trigger conditions | Additional data |
---|---|---|
events.viewShown | When the search view is shown. | None. |
events.viewHidden | When the search view is hidden. | None. |
events.searchSelected | When the search input view is selected. | None. |
events.poiSelected | When a Point of Interest (POI) is selected from the search results. | (Number,String) If a poi is selected it will return fid of the selected poi. If a building is selected it will return the building id. |
events.searchCleared | When the search input is cleared. | None. |
events.resultsPopulated | When the search results are populated. | None. |
events.querySearched | When a query is searched. | (String) query string that is searched. |
events.routeButtonClicked | When the route button is clicked. | None. |
events.goBackButtonClicked | When the back button is clicked. | None. |
events.buildingFilterSelected | When a building filter is selected. | (Number) selected building id. |
events.searchResultsShown | When the search results are shown. | None. |
PoiDetailsView Events¶
Available events for the PoiDetailsView component can be accessed as follows:
const events = pointrWeb
.getUiController()
.getPoiDetailsViewController()
.getView().events;
PoiDetailsView Events | Trigger conditions | Additional data |
---|---|---|
events.viewShown | When the Point of Interest (POI) details view is shown. | None. |
events.viewHidden | When the Point of Interest (POI) details view is hidden. | None. |
events.closeClicked | When the close button is clicked. | None. |
events.routeButtonClicked | When the route button is clicked. | None. |
events.poiButtonClicked | When one of the buttons on the POI Details view is clicked. (Available after 8.4.0) | (Object) { name: String, action: String, intent: String, iconUrl: String }. |
NavigationView Events¶
Available events for the NavigationView component can be accessed as follows:
const events = pointrWeb
.getUiController()
.getNavigationViewController()
.getView().events;
NavigationView Events | Trigger conditions | Additional data |
---|---|---|
events.viewShown | When the navigation view is shown. | None. |
events.viewHidden | When the navigation view is hidden. | None. |
events.startSelected | When the start POI or Point is selected. | (Object) Poi or Feature object. If selection is a POI, it will return the POI object. If selection is a custom point, it will return the feature object. |
events.destinationSelected | When the destination POI or Point is selected. | (Object) Poi or Feature object. If selection is a POI, it will return the POI object. If selection is a custom point, it will return the feature object. |
events.navigateClicked | When the navigate button is clicked. | (String, String) names of the start and destination POIs. |
events.routeChanged | When the route is changed. | None. |
events.navigationCancelled | When the Directions (navigation) is cancelled using start/destination edit buttons. | None. |
events.navigationClosed | When the Directions (navigation) is closed using the X button or the top right Close directions button. | None. |
events.previousStepSelected | When the previous step button is clicked. | None. |
events.nextStepSelected | When the next step button is clicked. | None. |
events.inputsSwapped | When the start and destination inputs are swapped. | None. |
events.queryChanged | When the search query is changed in the navigation view. | (Object) {query: String, type: String("start","destination")} |
events.startObjectCanceled | When the start object is cancelled. | None. |
events.destinationObjectCanceled | When the destination object is cancelled. | None. |
CategoryListView Events¶
Available events for the CategoryListView component can be accessed as follows:
const events = pointrWeb
.getUiController()
.getCategoryListViewController()
.getView().events;
CategoryListView Events | Trigger conditions | Additional data |
---|---|---|
events.viewShown | When the category list view is shown. | None. |
eevents.viewHidde | When the category list view is hidden. | None. |
events.categorySelected | When a category is selected. | (Object) {iconUrl: String, title: String, typeCodes: Array of String}. |
PoiCardsView Events¶
Available events for the PoiCardsView component can be accessed as follows:
const events = pointrWeb
.getUiController()
.getPoiCardsViewController()
.getView().events;
PoiCardsView Events | Trigger conditions | Additional data |
---|---|---|
events.viewShown | When the Point of Interest (POI) cards view is shown. | None. |
events.viewHidden | When the Point of Interest (POI) cards view is hidden. | None. |
events.poiSelected | When a Point of Interest (POI)’s detail button is clicked | (String) fid of the selected POI. |
events.resultsPopulated | When the Point of Interest (POI) cards are populated. | None. |
events.routeButtonClicked | When the route button is clicked. | None. |
events.goBackButtonClicked | When the back button is clicked. | None. |
events.poiViewed | When a Point of Interest (POI) is highlighted. | (String) fid of the selected POI. |
LanguageSelectorView Events¶
Available events for the LanguageSelectorView component can be accessed as follows:
const events = pointrWeb
.getUiController()
.getLanguageSelectorViewController()
.getView().events;
PoiCardsView Events | Trigger conditions | Additional data |
---|---|---|
events.viewShown | When the language selector view is shown. | None. |
events.viewHidden | When the language selector view is hidden. | None. |
events.languageSelected | When a language is selected.(Available after v8.2.0) | (Object) {title: String, code: String} |
events.expanded | events.expanded | None. |
events.shrunk | When the language selector view is shrunk. | None. |
RatingView Events¶
const events = pointrWeb
.getUiController()
.getRatingViewController()
.getView().events;
PoiCardsView Events | Trigger conditions | Additional data |
---|---|---|
events.viewShown | When the view is shown. (Available after v8.14.0) | None. |
events.viewHidden | When the view is hidden. (Available after v8.14.0) | None. |
events.feedbackSubmitted | When a feedback is submitted. (Available after v8.14.0) | None. |
events.dismissed**: fires when the rating popup is dismissed. (Available after v8.14.0) | None. |
InfoView Events¶
const events = pointrWeb
.getUiController()
.getInfoViewController()
.getView().events;
PoiCardsView Events | Trigger conditions | Additional data |
---|---|---|
events.viewShown | When the view is shown. (Available after v8.14.0) | None. |
events.viewHidden | When the view is hidden. (Available after v8.14.0) | None. |
LoadingView Events¶
const events = pointrWeb
.getUiController()
.getLoadingViewController()
.getView().events;
PoiCardsView Events | Trigger conditions | Additional data |
---|---|---|
events.viewShown | When the view is shown. | None. |
events.viewHidden | When the view is hidden. | None. |
events.errorShown | When the error page is shown. | None. |
events.errorHidden | When the error page is hidden. | None. |
events.errorClosed | When the close icon on the error popup is clicked. | None. |
WelcomeView Events¶
const events = pointrWeb
.getUiController()
.getWelcomeViewController()
.getView().events;
PoiCardsView Events | Trigger conditions | Additional data |
---|---|---|
events.viewShown | When the view is shown. (Available after v8.14.0) | None. |
events.viewHidden | When the view is hidden. (Available after v8.14.0) | None. |
events.closeClicked | When the close icon is clicked. (Available after v8.14.0) | None. |
Listener Pattern¶
Listener pattern is a very popular pattern in MVC design paradigm and most mobile frameworks. Pointr SDKs make heavy use of this pattern throughout the code. The most likely you will encounter this pattern is when working with Managers. Most managers (if not all) use this pattern to advertise events to their listeners.
For example, PoiManager
advertises when new POI data is available through its onPoiManagerChangedPoisForSite
callback method. Any party interested in the latest POI data should
- Add itself as a listener to
PoiManager
- eg.PoiManager.addListener(self)
- Implement callbacks of interest1 in your class
For all available callbacks, examine the relevant Listener class - eg. PoiManager
’s callbacks are defined in PoiManager.Listener
Warning
To avoid any race condition, always add listener before checking state/content. See below:
Correct implementation
Pointr.shared.poiManager.addListener(...)
var pois = Pointr.shared.poiManager.pois(...)
In this implementation, you always ensure you have the latest data
Incorrect implementation
(1) var pois = Pointr.shared.poiManager.pois(...)
(2) Pointr.shared.poiManager.addListener(...)
1: Javascript
and Swift
allows you to implement as many callbacks as you are interested in whilst Java
and Kotlin
force you to implement all callbacks.