AMapWidget constructor

const AMapWidget({
  1. Key? key,
  2. AMapPrivacyStatement? privacyStatement,
  3. AMapApiKey? apiKey,
  4. CameraPosition initialCameraPosition = const CameraPosition(target: LatLng(39.909187, 116.397451), zoom: 10),
  5. MapType mapType = MapType.normal,
  6. bool buildingsEnabled = true,
  7. bool compassEnabled = false,
  8. bool labelsEnabled = true,
  9. LatLngBounds? limitBounds,
  10. MinMaxZoomPreference? minMaxZoomPreference,
  11. bool rotateGesturesEnabled = true,
  12. bool scaleEnabled = true,
  13. bool scrollGesturesEnabled = true,
  14. bool tiltGesturesEnabled = true,
  15. bool touchPoiEnabled = true,
  16. bool trafficEnabled = false,
  17. bool zoomGesturesEnabled = true,
  18. bool gestureScaleByMapCenter = false,
  19. MapCreatedCallback? onMapCreated,
  20. Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers = const <Factory<OneSequenceGestureRecognizer>>{},
  21. CustomStyleOptions? customStyleOptions,
  22. MyLocationStyleOptions? myLocationStyleOptions,
  23. ArgumentCallback<CameraPosition>? onCameraMove,
  24. ArgumentCallback<CameraPosition>? onCameraMoveEnd,
  25. ArgumentCallback<AMapLocation>? onLocationChanged,
  26. ArgumentCallback<LatLng>? onTap,
  27. ArgumentCallback<LatLng>? onLongPress,
  28. ArgumentCallback<AMapPoi>? onPoiTouched,
  29. Set<Marker> markers = const <Marker>{},
  30. Set<Polyline> polylines = const <Polyline>{},
  31. Set<Polygon> polygons = const <Polygon>{},
})

创建一个展示高德地图的widget

如果使用的高德地图SDK的版本是8.1.0及以上版本, 在app首次启动时必须传入高德合规声明配置privacyStatement,后续如果没有变化不需要重复设置

  • [privacyStatement.hasContains] 隐私权政策是否包含高德开平隐私权政策
  • [privacyStatement.hasShow] 是否已经弹窗展示给用户
  • [privacyStatement.hasAgree] 隐私权政策是否已经取得用户同意
  • 以上三个值,任何一个为false都会造成地图插件不工作(白屏情况)

    高德SDK合规使用方案请参考:https://lbs.amap.com/news/sdkhgsy

    AssertionError will be thrown if initialCameraPosition is null;

    Implementation

    const AMapWidget({
      Key? key,
      this.privacyStatement,
      this.apiKey,
    
      this.initialCameraPosition = const CameraPosition(target: LatLng(39.909187, 116.397451), zoom: 10),
      this.mapType = MapType.normal,
      this.buildingsEnabled = true,
      this.compassEnabled = false,
      this.labelsEnabled = true,
      this.limitBounds,
      this.minMaxZoomPreference,
      this.rotateGesturesEnabled = true,
      this.scaleEnabled = true,
      this.scrollGesturesEnabled = true,
      this.tiltGesturesEnabled = true,
      this.touchPoiEnabled = true,
      this.trafficEnabled = false,
      this.zoomGesturesEnabled = true,
      this.gestureScaleByMapCenter = false,//新增,中心锁定缩放
      this.onMapCreated,
      this.gestureRecognizers = const <Factory<OneSequenceGestureRecognizer>>{},
      this.customStyleOptions,
      this.myLocationStyleOptions,
      this.onCameraMove,
      this.onCameraMoveEnd,
      this.onLocationChanged,
      this.onTap,
      this.onLongPress,
      this.onPoiTouched,
      this.markers = const <Marker>{},
      this.polylines = const <Polyline>{},
      this.polygons = const <Polygon>{},
    }) : super(key: key);