Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 43 additions & 17 deletions lib/src/mk_map_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -283,22 +283,10 @@ final class _MKMapViewState extends State<MKMapView>
final (
PlatformMapKind kind,
MKMapEmphasisStyle emphasisStyle,
showsTraffic,
pointOfInterestFilter,
) = switch (widget.preferredConfiguration) {
MKStandardMapConfiguration(
:final emphasisStyle,
:final showsTraffic,
:final pointOfInterestFilter,
) =>
(.standard, emphasisStyle, showsTraffic, pointOfInterestFilter),
MKHybridMapConfiguration(
:final showsTraffic,
:final pointOfInterestFilter,
) =>
(.hybrid, .standard, showsTraffic, pointOfInterestFilter),
MKImageryMapConfiguration() => (.imagery, .standard, false, null),
};
bool showsTraffic,
PlatformPointOfInterestFilter? pointOfInterestFilter,
) = widget.preferredConfiguration._platformProperties;

return PlatformMapConfiguration(
kind: kind,
emphasisStyle: emphasisStyle,
Expand All @@ -315,7 +303,7 @@ final class _MKMapViewState extends State<MKMapView>
isZoomEnabled: widget.isZoomEnabled,
isPitchEnabled: widget.isPitchEnabled,
selectableMapFeatures: widget.selectableMapFeatures.toList(),
pointOfInterestFilter: pointOfInterestFilter?.toPlatform(),
pointOfInterestFilter: pointOfInterestFilter,
cameraZoomRange: widget.cameraZoomRange.toPlatform(),
cameraBoundary: widget.cameraBoundary?.toPlatform(),
);
Expand Down Expand Up @@ -449,3 +437,41 @@ final class _MKMapViewState extends State<MKMapView>
void onDidFailToLocateUser(String error) =>
widget.onDidFailToLocateUser?.call(error);
}

extension on MKMapConfiguration {
(
PlatformMapKind,
MKMapEmphasisStyle,
bool,
PlatformPointOfInterestFilter?,
)
get _platformProperties => switch (this) {
MKStandardMapConfiguration(
:final emphasisStyle,
:final showsTraffic,
:final pointOfInterestFilter,
) =>
(
PlatformMapKind.standard,
emphasisStyle,
showsTraffic,
pointOfInterestFilter.toPlatform(),
),
MKHybridMapConfiguration(
:final showsTraffic,
:final pointOfInterestFilter,
) =>
(
PlatformMapKind.hybrid,
MKMapEmphasisStyle.standard,
showsTraffic,
pointOfInterestFilter.toPlatform(),
),
MKImageryMapConfiguration() => (
PlatformMapKind.imagery,
MKMapEmphasisStyle.standard,
false,
null,
),
};
}
Loading