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. MapCreatedCallback? onMapCreated,
  19. Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers = const <Factory<OneSequenceGestureRecognizer>>{},
  20. CustomStyleOptions? customStyleOptions,
  21. MyLocationStyleOptions? myLocationStyleOptions,
  22. ArgumentCallback<CameraPosition>? onCameraMove,
  23. ArgumentCallback<CameraPosition>? onCameraMoveEnd,
  24. ArgumentCallback<AMapLocation>? onLocationChanged,
  25. ArgumentCallback<LatLng>? onTap,
  26. ArgumentCallback<LatLng>? onLongPress,
  27. ArgumentCallback<AMapPoi>? onPoiTouched,
  28. Set<Marker> markers = const <Marker>{},
  29. Set<Polyline> polylines = const <Polyline>{},
  30. 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.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);