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 tileEnabled = false,
  9. String walkRoute = "",
  10. String areaLevel = "",
  11. String areaCode = "",
  12. bool labelsEnabled = true,
  13. LatLngBounds? limitBounds,
  14. MinMaxZoomPreference? minMaxZoomPreference,
  15. bool rotateGesturesEnabled = true,
  16. bool scaleEnabled = true,
  17. bool scrollGesturesEnabled = true,
  18. bool tiltGesturesEnabled = true,
  19. bool touchPoiEnabled = true,
  20. bool trafficEnabled = false,
  21. bool zoomGesturesEnabled = true,
  22. MapCreatedCallback? onMapCreated,
  23. Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers = const <Factory<OneSequenceGestureRecognizer>>{},
  24. CustomStyleOptions? customStyleOptions,
  25. MyLocationStyleOptions? myLocationStyleOptions,
  26. ArgumentCallback<CameraPosition>? onCameraMove,
  27. ArgumentCallback<CameraPosition>? onCameraMoveEnd,
  28. ArgumentCallback<AMapLocation>? onLocationChanged,
  29. ArgumentCallback<LatLng>? onTap,
  30. ArgumentCallback<LatLng>? onLongPress,
  31. ArgumentCallback<AMapPoi>? onPoiTouched,
  32. Set<Marker> markers = const <Marker>{},
  33. Set<Polyline> polylines = const <Polyline>{},
  34. 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.tileEnabled = false,
      this.walkRoute = "",
      this.areaLevel = "",
      this.areaCode = "",
      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);