Skip to main content

Events

Contents

The Maps SDK provides several ways to listen and act upon events fired by the map. The generic listeners are mentioned below. However you may also find specific callbacks exist for specific APIs or uses.

Map click events

Click/Tap events can be listened for within the Map SDK. When set, the callback provided is fired when the user click’s or taps on the map. A LatLng object of where the user clicked is returned as part of the callback. The listeners are added to the TrimbleMapsMap object. Support is available for a regular click as well as a long click:

Map change events

While building or changing the map, the MapView object goes through many phases. There are a variety of listeners to use, allowing you to capture when a specific map event has triggered. These listeners are added to the MapView object rather than the TrimbleMapsMap object. For example:

There are a variety of other events available that are used in a similar manner to the above:

Listener Description
OnCameraWillChangeListener Map region is about to change
OnCameraDidChangeListener Map region completed change
OnWillStartLoadingMapListener Map about to start loading a new style
OnWillStartRenderingMapListener Map about to start rendering
addOnWillStartRenderingFrameListener Map is about to start rendering a frame
OnDidFinishRenderingFrameListener Map finished rendering the frame
OnDidFinishLoadingStyleListener Style finished loading
OnSourceChangedListener A source has changed
OnDidFinishLoadingMapListener Map finished loading loading a style
OnDidFinishRenderingMapListener Map has fully rendered

Camera change events

The map’s camera is used to define how the map is viewed; zoom level, rotation, etc. Go here for more details on the Camera itself. There are a few callbacks that you can listen to that relate to some of the camera’s movements, usually related around the beginning and end of a camera movement. See an example below:

These listeners are added to the TrimbleMapsMap object. Other listeners are in the table below:

Listener Description
OnCameraMove The camera is moving
OnCameraMoveCancel The camera’s movement was cancelled
OnCameraIdle Camera movement has ended

Movement events

Separately from the camera movement events, there are also listeners that can be fired after the user moves or flings the map. If the user uses a single finger to move the screen, this is considered a “Move” event. If the user does the same action but with more momentum, that is considered a “Fling”. These events are registered on a TrimbleMapsMap object.

Last updated October 18, 2023.
Contents