InteractiveMap<T>.delivery constructor

InteractiveMap<T>.delivery({
  1. Key? key,
  2. required List<T> items,
  3. required LatLng positionMapper(
    1. T item
    ),
  4. required Widget markerBuilder(
    1. BuildContext context,
    2. T item,
    3. int index
    ),
  5. void onDeliveryTapped(
    1. T item,
    2. int index
    )?,
  6. InteractiveMapController<T>? controller,
  7. LatLng initialCenter = const LatLng(45.4642, 9.1900),
  8. Color clusterColor = Colors.orange,
  9. double markerWidth = 80.0,
  10. double markerHeight = 80.0,
  11. double? focusedZoom = 15.0,
  12. MapInteractionConfig<T>? interaction,
  13. MapThemeConfig? theme,
  14. MapUserLocationConfig? userLocation,
  15. MapControlConfig? zoomConfig,
})

Factory tailored for Delivery Tracking.

Implementation

factory InteractiveMap.delivery({
  Key? key,
  required List<T> items,
  required LatLng Function(T item) positionMapper,
  required Widget Function(BuildContext context, T item, int index)
  markerBuilder,
  void Function(T item, int index)? onDeliveryTapped,
  InteractiveMapController<T>? controller,
  LatLng initialCenter = const LatLng(45.4642, 9.1900),
  Color clusterColor = Colors.orange,
  double markerWidth = 80.0,
  double markerHeight = 80.0,
  double? focusedZoom = 15.0,
  MapInteractionConfig<T>? interaction,
  MapThemeConfig? theme,
  MapUserLocationConfig? userLocation,
  MapControlConfig? zoomConfig,
}) {
  return InteractiveMap<T>(
    key: key,
    items: items,
    positionMapper: positionMapper,
    markerBuilder: markerBuilder,
    controller: controller,
    initialCenter: initialCenter,
    initialZoom: 12.0,
    markerWidth: markerWidth,
    markerHeight: markerHeight,
    theme: theme ?? const MapThemeConfig(),
    compassConfig: null,
    userLocation: userLocation,
    zoomConfig: zoomConfig,
    interaction:
        interaction ??
        MapInteractionConfig<T>(
          onTapItem: onDeliveryTapped,
          enableRotation: false,
          showCompass: false,
          focusedZoom: focusedZoom,
        ),
    clustering: MapClusteringConfig(
      maxZoom: 16,
      fitBoundsPadding: const EdgeInsets.all(80.0),
      clusterBuilder: (context, markers) => Container(
        decoration: BoxDecoration(
          color: clusterColor,
          shape: BoxShape.circle,
          border: Border.all(color: Colors.white, width: 2),
        ),
        child: Center(
          child: Text(
            markers.length.toString(),
            style: const TextStyle(
              color: Colors.white,
              fontWeight: FontWeight.bold,
            ),
          ),
        ),
      ),
    ),
  );
}