我正在使用google_maps_flutter。我的小部件树是Scaffold-> SingleChildScrollView-> Stack,然后是google map。我无法使用手势放大和缩小。
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(),
),
答案 0 :(得分:3)
SingleChildScrollView仅支持用于滚动的垂直拖动。
将gestureRecognizers
与EagerGestureRecognizer
添加到Traceback (most recent call last):
File "list.py", line 6, in <module>
engine = create_engine(os.getenv("data_sample"))
File "/Users/admin/.pyenv/versions/3.7.3/lib/python3.7/site-packages /sqlalchemy/engine/__init__.py", line 500, in create_engine
return strategy.create(*args, **kwargs)
File "/Users/admin/.pyenv/versions/3.7.3/lib/python3.7/site-packages/sqlalchemy/engine/strategies.py", line 56, in create
plugins = u._instantiate_plugins(kwargs)
AttributeError: 'NoneType' object has no attribute '_instantiate_plugins'
小部件将允许分派视图范围内的所有触摸事件。这包括2个手指捏合手势,用于放大和缩小地图。这将需要以下flutter软件包:
GoogleMap
将此添加到您的import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
小部件中:
GoogleMap
这是示例代码:
gestureRecognizers: < Factory < OneSequenceGestureRecognizer >> [
new Factory < OneSequenceGestureRecognizer > (
() => new EagerGestureRecognizer(),
),
].toSet()
我希望这会有所帮助!在您的项目中祝好运