Google map in Flutter not responding to touch events
You need to tell the GoogleMap
widget which gestures you want it to respond to by setting the gestureRecognizers
property, something like this:
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
...
GoogleMap(
initialCameraPosition: CameraPosition(
target: LatLng(0, 0),
),
gestureRecognizers: Set()
..add(Factory<PanGestureRecognizer>(() => PanGestureRecognizer()))
);
This is not specific to the GoogleMap
widget, you would need to do this with any widget that uses AndroidView
/UIKitView
under the covers to handle gestures when it's placed inside a scrollable view.
I was with the same problem and I found the following solution after a long time of searching, just so it will work:
GoogleMap(
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
new Factory<OneSequenceGestureRecognizer>(() => new EagerGestureRecognizer(),),
].toSet(),)
The reason is that the EagerGestureRecognizer
is a gesture recognizer that eagerly claims victory in all gesture arenas.
Reference:
Manage gestures priority between two widgets
propriedade gestureRecognizers
I think it depends of what kind of gestures your parent widget support.
This way works for me. My map is in TabBarView > ListView > GoogleMap
GoogleMap(
gestureRecognizers: Set()
..add(Factory<PanGestureRecognizer>(() => PanGestureRecognizer()))
..add(Factory<ScaleGestureRecognizer>(() => ScaleGestureRecognizer()))
..add(Factory<TapGestureRecognizer>(() => TapGestureRecognizer()))
..add(Factory<VerticalDragGestureRecognizer>(
() => VerticalDragGestureRecognizer())),