Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add specific options for apple maps and google maps #72

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
.vscode/

# Flutter/Dart/Pub related
**/doc/api/
Expand Down
2 changes: 2 additions & 0 deletions packages/platform_maps_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ flutter:
default_package: platform_maps_flutter_google_android
ios:
default_package: platform_maps_flutter_apple
web:
default_package: platform_maps_flutter_google_android

dependencies:
flutter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class _PlatformMap extends StatefulWidget {
/// Type of map tiles to be rendered.
MapType get mapType => params.mapType;

/// The colorscheme to be used for the map.
MapColorScheme get mapColorScheme => params.mapColorScheme;

/// Preferred bounds for the camera zoom level.
///
/// Actual bounds depend on map data and device.
Expand Down Expand Up @@ -142,6 +145,11 @@ class _PlatformMap extends StatefulWidget {
/// Enables or disables the traffic layer of the map
bool get trafficEnabled => params.trafficEnabled;

/// A Boolean value indicating whether the view's layout margins are updated
/// automatically to reflect the safe area.
bool get insetsLayoutMarginsFromSafeArea =>
params.insetsLayoutMarginsFromSafeArea;

/// Which gestures should be consumed by the map.
///
/// It is possible for other gesture recognizers to be competing with the map on pointer
Expand All @@ -165,6 +173,7 @@ class _PlatformMapState extends State<_PlatformMap> {
widget.initialCameraPosition.appleMapsCameraPosition,
compassEnabled: widget.compassEnabled,
mapType: _getMapType(),
colorScheme: _getAppleMapColorScheme(),
padding: widget.padding,
annotations: widget.markers.appleMapsAnnotationSet,
polylines: widget.polylines.appleMapsPolylineSet,
Expand All @@ -184,6 +193,7 @@ class _PlatformMapState extends State<_PlatformMap> {
onTap: _onTap,
onLongPress: _onLongPress,
trafficEnabled: widget.trafficEnabled,
insetsLayoutMarginsFromSafeArea: widget.insetsLayoutMarginsFromSafeArea,
minMaxZoomPreference: widget.minMaxZoomPreference.appleMapsZoomPreference,
);
}
Expand Down Expand Up @@ -214,4 +224,15 @@ class _PlatformMapState extends State<_PlatformMap> {
return apple_maps.MapType.hybrid;
}
}

apple_maps.MapColorScheme _getAppleMapColorScheme() {
if (widget.mapColorScheme == MapColorScheme.system) {
return apple_maps.MapColorScheme.system;
} else if (widget.mapColorScheme == MapColorScheme.light) {
return apple_maps.MapColorScheme.light;
} else if (widget.mapColorScheme == MapColorScheme.dark) {
return apple_maps.MapColorScheme.dark;
}
return apple_maps.MapColorScheme.system;
}
}
8 changes: 5 additions & 3 deletions packages/platform_maps_flutter_apple/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repository: https://github.com/albert-heijn-technology/platform_maps_flutter/tre
issue_tracker: https://github.com/albert-heijn-technology/platform_maps_flutter/issues

environment:
sdk: '>=3.2.4 <4.0.0'
sdk: ">=3.2.4 <4.0.0"
flutter: ">=1.17.0"

flutter:
Expand All @@ -20,11 +20,13 @@ flutter:
dependencies:
flutter:
sdk: flutter
apple_maps_flutter: ^1.3.0
apple_maps_flutter:
git:
url: https://github.com/Iconica-Development/apple_maps_flutter
ref: master
platform_maps_flutter_platform_interface: ^1.0.0-beta

dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0

Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ class _PlatformMap extends StatefulWidget {
/// Enables or disables the traffic layer of the map
bool get trafficEnabled => params.trafficEnabled;

/// The optional style to be used for the map. See https://developers.google.com/maps/documentation/android-sdk/styling for more details.
String? get googleMapsStyle => params.googleMapsStyle;

/// The optional mapId to be used for the map. See https://developers.google.com/maps/documentation/android-sdk/cloud-based-map-styling for more details.
String? get googleMapsCloudMapId => params.googleMapsCloudMapId;

/// Which gestures should be consumed by the map.
///
/// It is possible for other gesture recognizers to be competing with the map on pointer
Expand Down Expand Up @@ -188,6 +194,8 @@ class _PlatformMapState extends State<_PlatformMap> {
onTap: _onTap,
onLongPress: _onLongPress,
trafficEnabled: widget.trafficEnabled,
cloudMapId: widget.googleMapsCloudMapId,
style: widget.googleMapsStyle,
minMaxZoomPreference:
widget.minMaxZoomPreference.googleMapsZoomPreference,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class PlatformMap extends StatelessWidget {
this.polygons = const <Polygon>{},
this.polylines = const <Polyline>{},
this.circles = const <Circle>{},
this.googleMapsStyle,
this.googleMapsCloudMapId,
this.onCameraMoveStarted,
this.onCameraMove,
this.onCameraIdle,
Expand Down Expand Up @@ -189,6 +191,12 @@ class PlatformMap extends StatelessWidget {
/// were not claimed by any other gesture recognizer.
final Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers;

/// The style of the map. This is only supported for google maps.
final String? googleMapsStyle;

/// The cloud map id of the map. This is only supported for google maps.
final String? googleMapsCloudMapId;

final PlatformMapsPlatformWidget _platform;

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export 'types/info_window.dart';
export 'types/joint_type.dart';
export 'types/lat_lng.dart';
export 'types/map_type.dart';
export 'types/map_colorscheme.dart';
export 'types/marker.dart';
export 'types/min_max_zoom_preference.dart';
export 'types/platform_maps_platform_widget_creation_params.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// Enum for the color scheme options for the map.
enum MapColorScheme {
/// Follow system settings for light/dark mode
system,

/// Light color scheme
light,

/// Dark color scheme
dark,
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ enum MapType {

/// Hybrid tiles (satellite images with some labels/overlays)
hybrid,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class PlatformMapsPlatformWidgetCreationParams {
this.gestureRecognizers = const <Factory<OneSequenceGestureRecognizer>>{},
this.compassEnabled = true,
this.mapType = MapType.normal,
this.mapColorScheme = MapColorScheme.system,
this.minMaxZoomPreference = MinMaxZoomPreference.unbounded,
this.rotateGesturesEnabled = true,
this.scrollGesturesEnabled = true,
Expand All @@ -24,12 +25,15 @@ class PlatformMapsPlatformWidgetCreationParams {
this.tiltGesturesEnabled = true,
this.myLocationEnabled = false,
this.myLocationButtonEnabled = false,
this.insetsLayoutMarginsFromSafeArea = false,
this.padding = const EdgeInsets.all(0),
this.trafficEnabled = false,
this.markers = const <Marker>{},
this.polygons = const <Polygon>{},
this.polylines = const <Polyline>{},
this.circles = const <Circle>{},
this.googleMapsStyle,
this.googleMapsCloudMapId,
this.onCameraMoveStarted,
this.onCameraMove,
this.onCameraIdle,
Expand All @@ -51,6 +55,9 @@ class PlatformMapsPlatformWidgetCreationParams {
/// Type of map tiles to be rendered.
final MapType mapType;

/// The colorscheme to be used when the map is on apple maps. There is no support for darkmode on google maps yet.
final MapColorScheme mapColorScheme;

/// Preferred bounds for the camera zoom level.
///
/// Actual bounds depend on map data and device.
Expand Down Expand Up @@ -157,6 +164,16 @@ class PlatformMapsPlatformWidgetCreationParams {
/// Enables or disables the traffic layer of the map
final bool trafficEnabled;

/// A Boolean value indicating whether the view's layout margins are updated
/// automatically to reflect the safe area.
final bool insetsLayoutMarginsFromSafeArea;

/// The style of the map. This is only supported for google maps.
final String? googleMapsStyle;

/// The cloud map id of the map. This is only supported for google maps.
final String? googleMapsCloudMapId;

/// Which gestures should be consumed by the map.
///
/// It is possible for other gesture recognizers to be competing with the map on pointer
Expand Down