flutter_map Docs
Project Links💝 Support Us
v5
v5
  • flutter_map
  • How Does It Work?
    • Raster vs Vector Tiles
  • Supporters
  • Getting Started
    • Installation
    • Quickstart
    • Examples
    • Migrating To v5
  • Usage
    • Base Widget
    • Options
    • Layers
    • Controller
    • Event Handling
    • Full API Reference
  • Layers
    • Tile Layer
      • Tile Providers
    • Marker Layer
    • Polygon Layer
    • Polyline Layer
    • Circle Layer
    • Overlay Image Layer
    • Attribution Layer
    • WMS Usage
  • Plugins
    • Plugins List
    • Making A Plugin
      • Creating New Tile Providers
      • Creating New Layers
  • Tile Servers
    • Using Mapbox
    • Using Thunderforest
    • Using Stadia Maps
    • Offline Mapping
    • Other Options
  • Frequently Asked Questions
  • Contributing
  • Credits
Powered by GitBook

© flutter_map Authors & Maintainers

On this page
  • Catching All Events
  • Catching Specific Events

Was this helpful?

Export as PDF
  1. Usage

Event Handling

PreviousControllerNextTile Layer

Last updated 1 year ago

Was this helpful?

If building a custom layer (Creating New Layers), consider using FlutterMapState directly instead.

When changes happen to FlutterMap's internal state, such as a change to the current position or zoom, it emits a MapEvent, which can be handled by you.

Catching All Events

There's two ways to catch all emitted MapEvents, and use them/the Stream<MapEvent> directly.

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.

  • Listening to a 's mapEventStream

  • 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 MapEvents. Instead, MapOptions has callbacks available for the following events:

  • onTap

  • onLongPress

  • onPositionChanged

  • onPointerDown/onPointerUp/onPointerHover/onPointerCancel

  • onMapReady Primarily used for advanced MapController

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 .doubleTapZoom:

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

This disables the double tap handler, so the MapEventTap is emitted 'instantly' on tap.

MapController
Usage In initState()
InteractiveFlag