Interact with the map

User Interface Events

This page outlines the interactive events and state change notifications you can listen for and handle programmatically when working with 3D maps. JavaScript within the browser is event-driven, meaning it responds to user interactions by generating events that your program can listen to and execute code accordingly.

There are two main types of events:

  • User interaction events (such as mouse clicks) are propagated from the 3D map viewport to your code. These events allow you to respond to direct user actions within the 3D map environment.
  • State change notifications reflect updates to the underlying 3D map data models and rendering state, using a conventional property_changed naming scheme.

Each 3D mapping API object exposes a set of named events that your program can register event listeners for and execute logic when those events occur using the built-in addEventListener() function. The following example illustrates common events triggered as a user interacts with a 3D map.

The following example shows which events are triggered as a user interacts with the map:

Camera restrictions

It may be desirable for you to control the camera's pan, maximum altitude, or to create lat/lng bounds restricting a user's movement in a given map. You can do this using camera restrictions.

For a example of how camera restrictions work and are implemented, take a look at the demo.