我正在开发一个谷歌地图。实际上,我想要这个功能当用户缩放地图或双击地图时定位它将表现得像一个uber应用程序。在uber中,map变为静态当用户缩放或双击但我找不到此功能时在颤振图中
我正在使用这个包google_maps_flutter:^2.1.1
Completer<GoogleMapController> completer;
GoogleMap(
myLocationEnabled: true,
myLocationButtonEnabled: false,
mapToolbarEnabled: false,
zoomGesturesEnabled: true,
zoomControlsEnabled: false,
rotateGesturesEnabled: false,
scrollGesturesEnabled: true,
tiltGesturesEnabled: false,
markers: locationData.locationMarkers.values.toSet(),
initialCameraPosition: CameraPosition(
target: LatLng(widget.lat, widget.long),
zoom: 16.4746,
),
onCameraMove: (position) {
latitude = position.target.latitude;
longitude = position.target.longitude;
},
onCameraIdle: () async {
if (latitude != null && longitude != null) {
print("not workng");
geoCodeProvider.setLatitude(latitude);
geoCodeProvider.setLongitude(longitude);
}
},
onMapCreated: (GoogleMapController controller) {
widget.completer.complete(controller);
},
)
您可以使用此代码在谷歌地图中添加手势
GoogleMap(
initialCameraPosition: CameraPosition(
target: LatLng(0, 0),
),
gestureRecognizers: Set()
..add(Factory<TapGestureRecognizer>(() => TapGestureRecognizer()))
);
用户与地图交互时处理缩放级别
GoogleMap(
zoomGesturesEnabled: true,
tiltGesturesEnabled: false,
onCameraMove:(CameraPosition cameraPosition){
print(cameraPosition.zoom);
},
)
将此添加到地图中的最小或最大缩放级别
minMaxZoomPreference: MinMaxZoomPreference(13,17)