我正在使用 google_maps_flutter 包,我需要将地图的可滚动区域限制为特定区域。我有西南角和东北角,但我不知道该怎么做。
我已经尝试了下面的代码,但它不起作用。
uniCampusSW 和 uniCampusNE 都是 LatLngs。
_userLocation == null // If user location has not been found
? Center(
// Display Progress Indicator
child: CircularProgressIndicator(
backgroundColor: UniColors.primaryColour[500],
),
)
: GoogleMap(
// Show Campus Map
onMapCreated: _onMapCreated,
initialCameraPosition: // required parameter that sets the starting camera position. Camera position describes which part of the world you want the map to point at.
CameraPosition(
target: _userLocation, zoom: defaultZoom, tilt: 0.0),
scrollGesturesEnabled: true,
tiltGesturesEnabled: true,
trafficEnabled: false,
compassEnabled: true,
rotateGesturesEnabled: true,
myLocationEnabled: true,
mapType: _currentMapType,
zoomGesturesEnabled: true,
cameraTargetBounds: new CameraTargetBounds(
new LatLngBounds(
northeast: UniCampusNE,
southwest: UniCampusSW,
),
),
),
这是我得到的错误
/flutter(12525):在构建 TheMap(脏,状态:_TheMapState#a8840)时引发了以下断言:I/flutter(12525):'package:google_maps_flutter/src/location.dart':断言失败:第 68 行 pos 16: I/flutter (12525): 'southwest.latitude <= northeast.latitude': 不正确。
谢谢