我的程序中有一个谷歌地图小部件。
child: GoogleMap(
mapType: state.isSatellite ? MapType.hybrid : MapType.normal,
myLocationButtonEnabled: false,
initialCameraPosition: CameraPosition(
target: LatLng(
widget.initialLocation.latitude,
widget.initialLocation.longitude,
),
zoom: widget.zoom,
),
tiltGesturesEnabled: false,
scrollGesturesEnabled: !widget.staticPosition,
gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{
Factory<OneSequenceGestureRecognizer>(
() => EagerGestureRecognizer(),
),
},
onCameraMove: (position) {
bloc.add(
SetLocation(location: (
latitude: position.target.latitude,
longitude: position.target.longitude,
)),
);
},
onCameraIdle: () {
if (widget.staticPosition) {
bloc.add(SetCameraPosition(widget.initialLocation));
}
},
onMapCreated: (GoogleMapController controller) async {
_controller.complete(controller);
if (state.currentLocation.latitude != 0 &&
state.currentLocation.longitude != 0) {
await controller.animateCamera(
CameraUpdate.newLatLng(
LatLng(
state.currentLocation.latitude,
state.currentLocation.longitude,
),
),
);
}
},
),
问题是这个在 singlechildscrollview 内,当我按住鼠标并拖动位置时,位置会发生变化,但页面也会被拖动。我不想让页面被拖拽。有什么想法吗?
我尝试了 AbsorbPointer() 和 IgnorePointer()。
在 Google 地图小部件中,您可以自定义手势识别器以避免冲突。