google-maps - GoogleMap 和 ListView 在同一个屏幕上
问题描述
我想让屏幕像顶部显示谷歌地图和一个过滤表单,然后最后显示垂直列表视图。我有很多尝试,但地图不是垂直滚动,它采用 listview 的滚动。
以及如何在地图中添加缩放加和缩放减按钮
我的小部件树就像 .. mapView 是 GoogleMap 小部件。
return ListView(
children: <Widget>[
SizedBox(height: mapHeight, child: MapView()),
ListView(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
children: <Widget>[
getForm(context),
getWorkerList(context)
],
) ,
],
);
像下面的另一个尝试但没有得到正确的输出
return ListView(
children: <Widget>[
SizedBox(
height: 300,
child: ListView(
//i want to disable listview scrolling when scroll on map
physics: NeverScrollableScrollPhysics(),
children: <Widget>[
Container(
height: 300,
child: MapView1()),
],
)),
getForm(context),
getWorkerList(context)
],
);
地图视图代码
@override
Widget build(BuildContext context) {
return GoogleMap(
mapToolbarEnabled: true,
myLocationEnabled: true,
zoomGesturesEnabled: true,
scrollGesturesEnabled: true,
rotateGesturesEnabled: true,
myLocationButtonEnabled: true,
gestureRecognizers: Set()
..add(
Factory<PanGestureRecognizer>(() => PanGestureRecognizer()))
..add(
Factory<VerticalDragGestureRecognizer>(
() => VerticalDragGestureRecognizer()),
)
..add(
Factory<HorizontalDragGestureRecognizer>(
() => HorizontalDragGestureRecognizer()),
)
..add(
Factory<ScaleGestureRecognizer>(
() => ScaleGestureRecognizer()),
),
initialCameraPosition: CameraPosition(
target: LatLng(41.143029, -8.611274),
zoom: _currentZoom,
),
markers: _markers,
onMapCreated: (controller) => _onMapCreated(controller),
onCameraMove: (position) => _updateMarkers(position.zoom),
);
}
期望的结果:
解决方案
将此行添加到您的 googlemap 小部件
gestureRecognizers: Set()..add(Factory<EagerGestureRecognizer>(() => EagerGestureRecognizer())),
像这样
GoogleMap(
mapType: MapType.normal,
initialCameraPosition: CameraPosition(
target: LatLng(double.parse(widget.latitude), double.parse(widget.longitude)),
zoom: 15.4746,
),
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
},
gestureRecognizers: Set()..add(Factory<EagerGestureRecognizer>(() => EagerGestureRecognizer())),
)
推荐阅读
- ios - Firebase Messenger Swift 的 UITableViewCell
- php - 处理程序未捕获 autohorization 和令牌不匹配异常。拉拉维尔
- javascript - 打开带有预先选中复选框的 HTML 页面
- php - PHP 连接到 Firebird 数据库
- ios - 在 iOS 上编译 Delphi Tokyo 10.2.3 时出错
- reactjs - 我想要单击删除按钮时的图像 ID
- android - 文本输入 (React Native - Android) - 支持 onKeyPreIme
- java - 更新谷歌应用引擎的 gradle 版本
- android - 获取推送通知的新令牌火力库 (FCM)
- java - 需要更新java中的toString方法