# Listen To Events

{% hint style="info" %}
To cause a widget inside `FlutterMap`'s context to rebuild when the [`MapCamera`](/v6/usage/programmatic-control/get-camera.md), [`MapOptions`](/v6/usage/options.md), or [`MapController`](/v6/usage/programmatic-control/controller.md) changes, see [Creating New Layers](/v6/plugins/making-a-plugin/creating-new-layers.md#hooking-into-inherited-state).

This page's methods should only be used to listen to events from outside the `FlutterMap`'s context.
{% endhint %}

When changes happen to `FlutterMap`'s internal state (such as a change to the current [`MapCamera`](/v6/usage/programmatic-control/get-camera.md)) it emits a `MapEvent`, which can be handled by you.

## Catching All Events

There's two methods to catch all emitted `MapEvent`s. These methods expose the raw `MapEvent`, and is recommended in cases where multiple events need to be caught, or there's no more specific callback method available in `MapOptions` (see [#catching-specific-events](#catching-specific-events "mention")).

* Listening to a [`MapController`](/v6/usage/programmatic-control/controller.md)'s `mapEventStream`, which exposes events via a `Stream`
* Specifying a callback method in `MapOptions.onMapEvent`

## Catching Specific Events

If only a couple of events need to be caught, such as just an `onTap` handler, it is possible to avoid handling the raw `Stream` of `MapEvent`s. Instead, `MapOptions` has callbacks available for the following events:

* `onTap`
* `onLongPress`
* `onPositionChanged`
* `onPointerDown`/`onPointerUp`/`onPointerHover`/`onPointerCancel`
* `onMapReady`\
  Primarily used for advanced `MapController` [Control Camera](/v6/usage/programmatic-control/controller.md#usage-inside-initstate)

{% hint style="info" %}
The `MapEventTap` event may be emitted (or the `onTap` callback called) 250ms after the actual tap occurred, as this is the acceptable delay between the two taps in a double tap zoom gesture.

If this causes noticeable jank or a bad experience (for example, on desktop platforms), disable [`InteractiveFlag`](/v6/usage/options/interaction-options.md#flags)`.doubleTapZoom`:

```dart
options: MapOptions(
    interactiveFlags: ~InteractiveFlag.doubleTapZoom,
),
```

This disables the double tap handler, so the `MapEventTap` is emitted 'instantly' on tap.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fleaflet.dev/v6/usage/programmatic-control/listen-to-events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
