VietmapController constructor
VietmapController({
- required VietmapGlPlatform vietmapGLPlatform,
- required CameraPosition initialCameraPosition,
- required Iterable<
AnnotationType> annotationOrder, - required Iterable<
AnnotationType> annotationConsumeTapEvents, - OnStyleLoadedCallback? onStyleLoadedCallback,
- OnMapClickCallback? onMapClick,
- OnMapLongClickCallback? onMapLongClick,
- OnAnnotationUpdate? onAnnotationUpdate,
- OnDidFinishedRenderingFrame? onDidFinishedRenderingFrame,
- OnCameraTrackingDismissedCallback? onCameraTrackingDismissed,
- OnCameraTrackingChangedCallback? onCameraTrackingChanged,
- OnMapIdleCallback? onMapIdle,
- OnMapRenderedCallback? onMapRendered,
- OnMapRenderedCallback? onMapFirstRendered,
- OnUserLocationUpdated? onUserLocationUpdated,
- OnCameraIdleCallback? onCameraIdle,
Implementation
VietmapController({
required VietmapGlPlatform vietmapGLPlatform,
required CameraPosition initialCameraPosition,
required Iterable<AnnotationType> annotationOrder,
required Iterable<AnnotationType> annotationConsumeTapEvents,
this.onStyleLoadedCallback,
this.onMapClick,
this.onMapLongClick,
this.onAnnotationUpdate,
this.onDidFinishedRenderingFrame,
//this.onAttributionClick,
this.onCameraTrackingDismissed,
this.onCameraTrackingChanged,
this.onMapIdle,
this.onMapRendered,
this.onMapFirstRendered,
this.onUserLocationUpdated,
this.onCameraIdle,
}) : _vietmapGLPlatform = vietmapGLPlatform {
_cameraPosition = initialCameraPosition;
var isFirstRenderedCalled = false;
// _vietmapGLPlatform.onAnnotationUpdate.add((data) {
// onAnnotationUpdate?.call(data);
// });
// _vietmapGLPlatform.onDidFinishedRenderingFrame.add((_) {
// onDidFinishedRenderingFrame?.call();
// });
_vietmapGLPlatform.onFeatureTappedPlatform.add((payload) {
for (final fun
in List<OnFeatureInteractionCallback>.from(onFeatureTapped)) {
fun(payload["id"], payload["point"], payload["latLng"],
payload["layerId"]);
}
});
// _vietmapGLPlatform.onDidFinishedRenderingFrame.add((_) {
// onDidFinishedRenderingFrame?.call();
// });
_vietmapGLPlatform.onMapRenderedPlatform.add((_) {
onMapRendered?.call();
if (onMapFirstRendered != null && !isFirstRenderedCalled) {
onMapFirstRendered!();
isFirstRenderedCalled = true;
}
});
_vietmapGLPlatform.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);
}
});
_vietmapGLPlatform.onCameraMoveStartedPlatform.add((_) {
_isCameraMoving = true;
notifyListeners();
});
_vietmapGLPlatform.onCameraMovePlatform.add((cameraPosition) {
_cameraPosition = cameraPosition;
notifyListeners();
});
_vietmapGLPlatform.onCameraIdlePlatform.add((cameraPosition) {
_isCameraMoving = false;
if (cameraPosition != null) {
_cameraPosition = cameraPosition;
}
onCameraIdle?.call();
notifyListeners();
});
_vietmapGLPlatform.onMapStyleLoadedPlatform.add((_) {
final interactionEnabled = annotationConsumeTapEvents.toSet();
for (final type in annotationOrder.toSet()) {
final enableInteraction = interactionEnabled.contains(type);
switch (type) {
case AnnotationType.polygon:
polygonManager = PolygonManager(this,
onTap: onPolygonTapped.call,
enableInteraction: enableInteraction);
case AnnotationType.line:
polylineManager = PolylineManager(this,
onTap: onPolylineTapped.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();
});
_vietmapGLPlatform.onMapClickPlatform.add((dict) {
onMapClick?.call(dict['point'], dict['latLng']);
});
_vietmapGLPlatform.onMapLongClickPlatform.add((dict) {
onMapLongClick?.call(dict['point'], dict['latLng']);
});
_vietmapGLPlatform.onCameraTrackingChangedPlatform.add((mode) {
onCameraTrackingChanged?.call(mode);
});
_vietmapGLPlatform.onCameraTrackingDismissedPlatform.add((_) {
onCameraTrackingDismissed?.call();
});
_vietmapGLPlatform.onMapIdlePlatform.add((_) {
onMapIdle?.call();
});
_vietmapGLPlatform.onUserLocationUpdatedPlatform.add((location) {
onUserLocationUpdated?.call(location);
});
}