Google maps 谷歌地图颤振手势在堆栈中不起作用

Google maps 谷歌地图颤振手势在堆栈中不起作用,google-maps,flutter,Google Maps,Flutter,我正在使用谷歌地图。我的小部件树是Scaffold->SingleChildScrollView->Stack,然后是googlemap。我无法使用手势放大和缩小 SingleChildScrollView( Stack( children: <Widget>[ Container( height: MediaQuery.of(context).size.height - 10.0,

我正在使用谷歌地图。我的小部件树是Scaffold->SingleChildScrollView->Stack,然后是googlemap。我无法使用手势放大和缩小

SingleChildScrollView( Stack(
            children: <Widget>[
              Container(
                height: MediaQuery.of(context).size.height - 10.0,
                width: MediaQuery.of(context).size.width * 1,
                child: _mapView
                    ? GoogleMap(
                        initialCameraPosition: CameraPosition(
                            target: _outletData[0].locationCoords, zoom: 12.0),
                        markers: Set.from(allMarkers),
                        onMapCreated: mapCreated,
                        zoomControlsEnabled: false,
                        zoomGesturesEnabled: true,
                        scrollGesturesEnabled: true,
                        compassEnabled: true,
                        rotateGesturesEnabled: true,
                        mapToolbarEnabled: true,
                        tiltGesturesEnabled: true,
                       
                      )
                    : Container(),
              ),
我也尝试了下面的代码,但仍然无法用两个手指触摸放大缩小

Stack(
            children: <Widget>[
              Container(
                height: MediaQuery.of(context).size.height - 10.0,
                width: MediaQuery.of(context).size.width * 1,
                child: _mapView
                    ? GoogleMap(
                        initialCameraPosition: CameraPosition(
                            target: _outletData[0].locationCoords, zoom: 12.0),
                        markers: Set.from(allMarkers),
                        onMapCreated: mapCreated,
                        zoomControlsEnabled: false,
                        zoomGesturesEnabled: true,
                        scrollGesturesEnabled: true,
                        compassEnabled: true,
                        rotateGesturesEnabled: true,
                        mapToolbarEnabled: true,
                        tiltGesturesEnabled: true,
                        gestureRecognizers: Set()
                          ..add(Factory<PanGestureRecognizer>(
                              () => PanGestureRecognizer()))
                          ..add(Factory<ScaleGestureRecognizer>(
                              () => ScaleGestureRecognizer()))
                          ..add(Factory<TapGestureRecognizer>(
                              () => TapGestureRecognizer()))
                          ..add(
                            Factory<VerticalDragGestureRecognizer>(
                                () => VerticalDragGestureRecognizer()),
                          ),
                      )
                    : Container(),
              ),
仅支持用于滚动的垂直拖动

将with添加到GoogleMap小部件将允许调度视图边界内的所有触摸事件。这包括用于放大和缩小地图的2个手指捏手势。这将需要以下颤振包:

import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
在GoogleMap小部件中添加以下内容:

下面是一个示例代码:

GoogleMap(
    initialCameraPosition:
    CameraPosition(target: LatLng(-34.397, 150.644)),
    onMapCreated: _onMapCreated,
    zoomControlsEnabled: false,
    zoomGesturesEnabled: true,
    scrollGesturesEnabled: true,
    compassEnabled: true,
    rotateGesturesEnabled: true,
    mapToolbarEnabled: true,
    tiltGesturesEnabled: true,
    gestureRecognizers: < Factory < OneSequenceGestureRecognizer >> [
        new Factory < OneSequenceGestureRecognizer > (
            () => new EagerGestureRecognizer(),
        ),
    ].toSet()
)
我希望这有帮助!项目上的Goodluck只支持用于滚动的垂直拖动

将with添加到GoogleMap小部件将允许调度视图边界内的所有触摸事件。这包括用于放大和缩小地图的2个手指捏手势。这将需要以下颤振包:

import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
在GoogleMap小部件中添加以下内容:

下面是一个示例代码:

GoogleMap(
    initialCameraPosition:
    CameraPosition(target: LatLng(-34.397, 150.644)),
    onMapCreated: _onMapCreated,
    zoomControlsEnabled: false,
    zoomGesturesEnabled: true,
    scrollGesturesEnabled: true,
    compassEnabled: true,
    rotateGesturesEnabled: true,
    mapToolbarEnabled: true,
    tiltGesturesEnabled: true,
    gestureRecognizers: < Factory < OneSequenceGestureRecognizer >> [
        new Factory < OneSequenceGestureRecognizer > (
            () => new EagerGestureRecognizer(),
        ),
    ].toSet()
)

我希望这有帮助!祝你的项目好运

太棒了!很高兴它帮助了我:拯救了我的一天!!!令人惊叹的很高兴它帮助了我:拯救了我的一天!!!