MarkerController constructor
MarkerController({
- required Marker marker,
- InfoWindow? infoWindow,
- bool consumeTapEvents = false,
- LatLngCallback? onDragStart,
- LatLngCallback? onDrag,
- LatLngCallback? onDragEnd,
- VoidCallback? onTap,
- 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);
});
}
}