MarkerController constructor

MarkerController({
  1. required Marker marker,
  2. InfoWindow? infoWindow,
  3. bool consumeTapEvents = false,
  4. LatLngCallback? onDragStart,
  5. LatLngCallback? onDrag,
  6. LatLngCallback? onDragEnd,
  7. VoidCallback? onTap,
  8. ClusterManagerId? clusterManagerId,
})

Creates a MarkerController, which wraps a gmaps.Marker object, its onTap/onDrag behavior, and its associated gmaps.InfoWindow.

Implementation

MarkerController({
  required gmaps.Marker marker,
  gmaps.InfoWindow? infoWindow,
  bool consumeTapEvents = false,
  LatLngCallback? onDragStart,
  LatLngCallback? onDrag,
  LatLngCallback? onDragEnd,
  VoidCallback? onTap,
  ClusterManagerId? clusterManagerId,
})  : _marker = marker,
      _infoWindow = infoWindow,
      _consumeTapEvents = consumeTapEvents,
      _clusterManagerId = clusterManagerId {
  if (onTap != null) {
    marker.onClick.listen((gmaps.MapMouseEvent event) {
      onTap.call();
    });
  }
  if (onDragStart != null) {
    marker.onDragstart.listen((gmaps.MapMouseEvent event) {
      marker.position = event.latLng;
      onDragStart.call(event.latLng ?? _nullGmapsLatLng);
    });
  }
  if (onDrag != null) {
    marker.onDrag.listen((gmaps.MapMouseEvent event) {
      marker.position = event.latLng;
      onDrag.call(event.latLng ?? _nullGmapsLatLng);
    });
  }
  if (onDragEnd != null) {
    marker.onDragend.listen((gmaps.MapMouseEvent event) {
      marker.position = event.latLng;
      onDragEnd.call(event.latLng ?? _nullGmapsLatLng);
    });
  }
}