Working with map events

The Google Map's API allows us to listen for events on a map similar to those that we listen to on buttons and other views. The events that are available for this purpose are:

  • Map click / long click events
  • Camera change events
  • Indoor map events

Let's discuss these events in detail.

Map click/long click events

To handle map click events, we should use the OnMapClickListener interface on the GoogleMap object. To enable this, call the setOnMapClickListener() method on the GoogleMap object, which takes the GoogleMap.OnMapClickListener() interface as a parameter. When you click anywhere on a map, the onMapClick() method is called. In this example, we shall display a toast that shows the latitude and longitude of the location that ...

Get Learning Android Google Maps now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.