GebetaMapController constructor
GebetaMapController({
- required MapLibrePlatform maplibrePlatform,
- required CameraPosition initialCameraPosition,
- required Iterable<
AnnotationType> annotationOrder, - required Iterable<
AnnotationType> annotationConsumeTapEvents, - OnStyleLoadedCallback? onStyleLoadedCallback,
- OnMapClickCallback? onMapClick,
- OnMapLongClickCallback? onMapLongClick,
- OnCameraTrackingDismissedCallback? onCameraTrackingDismissed,
- OnCameraTrackingChangedCallback? onCameraTrackingChanged,
- OnMapIdleCallback? onMapIdle,
- OnUserLocationUpdated? onUserLocationUpdated,
- OnCameraIdleCallback? onCameraIdle,
Implementation
GebetaMapController({
required MapLibrePlatform maplibrePlatform,
required CameraPosition initialCameraPosition,
required Iterable<AnnotationType> annotationOrder,
required Iterable<AnnotationType> annotationConsumeTapEvents,
this.onStyleLoadedCallback,
this.onMapClick,
this.onMapLongClick,
//this.onAttributionClick,
this.onCameraTrackingDismissed,
this.onCameraTrackingChanged,
this.onMapIdle,
this.onUserLocationUpdated,
this.onCameraIdle,
}) : _maplibrePlatform = maplibrePlatform {
_cameraPosition = initialCameraPosition;
_maplibrePlatform.onFeatureTappedPlatform.add((payload) {
for (final fun
in List<OnFeatureInteractionCallback>.from(onFeatureTapped)) {
fun(payload["id"], payload["point"], payload["latLng"],
payload["layerId"]);
}
});
_maplibrePlatform.onFeatureDraggedPlatform.add((payload) {
for (final fun in List<OnFeatureDragnCallback>.from(onFeatureDrag)) {
final enmDragEventType = DragEventType.values
.firstWhere((element) => element.name == payload["eventType"]);
fun(payload["id"],
point: payload["point"],
origin: payload["origin"],
current: payload["current"],
delta: payload["delta"],
eventType: enmDragEventType);
}
});
_maplibrePlatform.onCameraMoveStartedPlatform.add((_) {
_isCameraMoving = true;
notifyListeners();
});
_maplibrePlatform.onCameraMovePlatform.add((cameraPosition) {
_cameraPosition = cameraPosition;
notifyListeners();
});
_maplibrePlatform.onCameraIdlePlatform.add((cameraPosition) {
_isCameraMoving = false;
if (cameraPosition != null) {
_cameraPosition = cameraPosition;
}
onCameraIdle?.call();
notifyListeners();
});
_maplibrePlatform.onMapStyleLoadedPlatform.add((_) {
final interactionEnabled = annotationConsumeTapEvents.toSet();
for (final type in annotationOrder.toSet()) {
final enableInteraction = interactionEnabled.contains(type);
switch (type) {
case AnnotationType.fill:
fillManager = FillManager(this,
onTap: onFillTapped.call, enableInteraction: enableInteraction);
case AnnotationType.line:
lineManager = LineManager(this,
onTap: onLineTapped.call, enableInteraction: enableInteraction);
case AnnotationType.circle:
circleManager = CircleManager(this,
onTap: onCircleTapped.call,
enableInteraction: enableInteraction);
case AnnotationType.symbol:
symbolManager = SymbolManager(this,
onTap: onSymbolTapped.call,
enableInteraction: enableInteraction);
}
}
onStyleLoadedCallback?.call();
});
_maplibrePlatform.onMapClickPlatform.add((dict) {
onMapClick?.call(dict['point'], dict['latLng']);
});
_maplibrePlatform.onMapLongClickPlatform.add((dict) {
onMapLongClick?.call(dict['point'], dict['latLng']);
});
_maplibrePlatform.onCameraTrackingChangedPlatform.add((mode) {
onCameraTrackingChanged?.call(mode);
});
_maplibrePlatform.onCameraTrackingDismissedPlatform.add((_) {
onCameraTrackingDismissed?.call();
});
_maplibrePlatform.onMapIdlePlatform.add((_) {
onMapIdle?.call();
});
_maplibrePlatform.onUserLocationUpdatedPlatform.add((location) {
onUserLocationUpdated?.call(location);
});
}