Flutter_map: Detect map onTap

Created on 27 Feb 2019  路  2Comments  路  Source: fleaflet/flutter_map

Hi,

Is it possible to detect if the user clicked in the map area?
For instance, I want to show information about a marker when the user tap on the marker and then remove that info when the user click in another place on the map. Is this possible?

Thanks in advance,

Most helpful comment

@BGomes17 yes it is possible. You can define an onTap in your MapOptions:

MapOptions(
  minZoom: 1.0,
  maxZoom: 19.0,
  zoom: 13.0,
  onTap: (point) => print(point),
  onLongPress: (point) => print(point),
  onPositionChanged: (position, hasGesture) => print("$position $hasGesture"),
  center: LatLng(0.0, 0.0),
)

All 2 comments

@BGomes17 yes it is possible. You can define an onTap in your MapOptions:

MapOptions(
  minZoom: 1.0,
  maxZoom: 19.0,
  zoom: 13.0,
  onTap: (point) => print(point),
  onLongPress: (point) => print(point),
  onPositionChanged: (position, hasGesture) => print("$position $hasGesture"),
  center: LatLng(0.0, 0.0),
)

Thank you very much, I was missing the parameter point in the onTap().
It worked like a charm.

Thank you,

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jacksos101 picture jacksos101  路  3Comments

garrrettt picture garrrettt  路  3Comments

aytunch picture aytunch  路  4Comments

reidterror picture reidterror  路  3Comments

JonasVautherin picture JonasVautherin  路  4Comments