MapBox static method

Universe MapBox({
  1. Key? key,
  2. MapBoxType type = MapBoxType.Street,
  3. required String accessToken,
  4. required dynamic center,
  5. TileLayerOptions? options,
  6. double? zoom,
  7. double? minZoom,
  8. double? maxZoom,
  9. double? rotation,
  10. bool? disableRotation,
  11. Color? background,
  12. MapController? controller,
  13. TileLayer? base,
  14. MarkerLayer? markers,
  15. CircleLayer? circles,
  16. PolylineLayer? polylines,
  17. PolygonLayer? polygons,
  18. RectangleLayer? rectangles,
  19. List<TileLayer> tiles = const [],
  20. List<ImageOverlay> images = const [],
  21. List<VideoOverlay> videos = const [],
  22. List<MapLayer> layers = const [],
  23. List<Widget> controls = const [],
  24. Crs? crs,
  25. Size? size,
  26. bool? live,
  27. bool? moveWhenLive,
  28. dynamic centerMarker,
  29. dynamic locationMarker,
  30. num? centerMarkerSize,
  31. num? locationMarkerSize,
  32. bool? showCenterMarker,
  33. bool? showLocator,
  34. Locator? locator,
  35. bool? showLocationMarker,
  36. bool? showLocationIndicator,
  37. LocationIndicator? locationIndicator,
  38. bool? showCompass,
  39. Compass? compass,
  40. bool? showScale,
  41. Scale? scale,
  42. bool? interactive,
  43. LatLngBounds? maxBounds,
  44. LatLngBounds? fitBounds,
  45. FitBoundsOptions? fitBoundsOptions,
  46. bool? slideOnBoundaries,
  47. bool? adaptiveBoundaries,
  48. bool? hideAttribution,
  49. dynamic onTap(
    1. LatLng?
    )?,
  50. dynamic onLongPress(
    1. LatLng?
    )?,
  51. MapChangedCallback? onChanged,
  52. Function? onReady,
})

Used to display map with base TileLayer from MapBox.

Example:

U.MapBox(
  type: MapBoxType.Street,
  accessToken: putYourAccessTokenHere,
  controller: MapController(),
  center: [-6.175329, 106.827253],
  zoom: 15,
)

@param: type

enum to define the type of MapBox tiles to load. Default value: MapBoxType.Street.

Available values: MapBoxType.Basic MapBoxType.Street MapBoxType.Satellite MapBoxType.Hybrid MapBoxType.Outdoors MapBoxType.Dark MapBoxType.Light MapBoxType.Bright

@param: center

Used to define center latlng position of the map. It can accept many types of value:

A list of two (or three) values that represents latitude and longitude (and altitude).

U.MapBox(
  type: MapBoxType.Street,
  accessToken: putYourAccessTokenHere,
  controller: MapController(),
  center: [-6.175329, 106.827253],
  zoom: 15,
)

or an instance of LatLng object:

U.MapBox(
  type: MapBoxType.Street,
  accessToken: putYourAccessTokenHere,
  controller: MapController(),
  center: LatLng(-6.175329, 106.827253),
  zoom: 15,
)

or location name.

The built-in GeoCoder inside will automatically convert it to latlng position for you.

Default to LatLng(0.0, 0.0) if your location is not found.

U.MapBox(
  type: MapBoxType.Street,
  accessToken: putYourAccessTokenHere,
  controller: MapController(),
  center: 'Emirates Stadium',
  zoom: 15,
)

Implementation

// ignore: non_constant_identifier_names
static Universe MapBox({
  Key? key,
  MapBoxType type = MapBoxType.Street,
  required String accessToken,
  required dynamic center,
  L.TileLayerOptions? options,
  double? zoom,
  double? minZoom,
  double? maxZoom,
  double? rotation,
  bool? disableRotation,
  Color? background,
  C.MapController? controller,
  L.TileLayer? base,
  L.MarkerLayer? markers,
  L.CircleLayer? circles,
  L.PolylineLayer? polylines,
  L.PolygonLayer? polygons,
  L.RectangleLayer? rectangles,
  List<L.TileLayer> tiles = const [],
  List<L.ImageOverlay> images = const [],
  List<L.VideoOverlay> videos = const [],
  List<L.MapLayer> layers = const [],
  List<Widget> controls = const [],
  Crs? crs,
  Size? size,
  bool? live,
  bool? moveWhenLive,
  dynamic centerMarker,
  dynamic locationMarker,
  num? centerMarkerSize,
  num? locationMarkerSize,
  bool? showCenterMarker,
  bool? showLocator,
  Locator? locator,
  bool? showLocationMarker,
  bool? showLocationIndicator,
  L.LocationIndicator? locationIndicator,
  bool? showCompass,
  Compass? compass,
  bool? showScale,
  Scale? scale,
  bool? interactive,
  LatLngBounds? maxBounds,
  LatLngBounds? fitBounds,
  FitBoundsOptions? fitBoundsOptions,
  bool? slideOnBoundaries,
  bool? adaptiveBoundaries,
  bool? hideAttribution,
  Function(LatLng?)? onTap,
  Function(LatLng?)? onLongPress,
  MapChangedCallback? onChanged,
  Function? onReady,
}) {
  if (type == MapBoxType.Dark) {
    background ??= const Color(0xFF555555);
  } else if (type == MapBoxType.Satellite || type == MapBoxType.Hybrid) {
    background ??= const Color(0xFF888888);
  } else {
    background ??= const Color(0xFFDEDEDE);
  }

  return U.Map(
    key: key,
    center: center,
    zoom: zoom,
    minZoom: minZoom,
    maxZoom: maxZoom,
    rotation: rotation,
    disableRotation: disableRotation,
    background: background,
    controller: controller,
    markers: markers,
    circles: circles,
    polylines: polylines,
    polygons: polygons,
    rectangles: rectangles,
    tiles: tiles,
    images: images,
    videos: videos,
    layers: layers,
    controls: controls,
    crs: crs,
    size: size,
    live: live,
    moveWhenLive: moveWhenLive,
    centerMarker: centerMarker,
    locationMarker: locationMarker,
    centerMarkerSize: centerMarkerSize,
    locationMarkerSize: locationMarkerSize,
    showCenterMarker: showCenterMarker,
    showLocator: showLocator,
    locator: locator,
    showLocationMarker: showLocationMarker,
    showLocationIndicator: showLocationIndicator,
    locationIndicator: locationIndicator,
    showCompass: showCompass,
    compass: compass,
    showScale: showScale,
    scale: scale,
    interactive: interactive,
    maxBounds: maxBounds,
    fitBounds: fitBounds,
    fitBoundsOptions: fitBoundsOptions,
    slideOnBoundaries: slideOnBoundaries,
    adaptiveBoundaries: adaptiveBoundaries,
    hideAttribution: hideAttribution,
    onTap: onTap,
    onLongPress: onLongPress,
    onChanged: onChanged,
    onReady: onReady,
    base: MapBoxTileLayer(type: type, accessToken: accessToken),
  );
}