Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 2.14.1

* Adds `colorScheme` support for web cloud-based maps styling brightness.
* Updates minimum supported SDK version to Flutter 3.32/Dart 3.8.

## 2.14.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@ flutter:
uses-material-design: true
assets:
- assets/
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
google_maps_flutter_platform_interface: {path: ../../../../packages/google_maps_flutter/google_maps_flutter_platform_interface}
google_maps_flutter_web: {path: ../../../../packages/google_maps_flutter/google_maps_flutter_web}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export 'package:google_maps_flutter_platform_interface/google_maps_flutter_platf
LatLng,
LatLngBounds,
MapBitmapScaling,
MapColorScheme,
MapStyleException,
MapType,
Marker,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class GoogleMap extends StatefulWidget {
this.onTap,
this.onLongPress,
this.cloudMapId,
this.colorScheme = MapColorScheme.followSystem,
});

/// Callback method for when the map is ready to be used.
Expand Down Expand Up @@ -373,6 +374,14 @@ class GoogleMap extends StatefulWidget {
/// for more details.
final String? cloudMapId;

/// Color scheme for the cloud-style map. Web only.
/// The colorScheme option can only be set when the map is initialized;
/// setting this option after the map is created will have no effect.
///
/// See https://developers.google.com/maps/documentation/javascript/mapcolorscheme
/// for more details.
final MapColorScheme colorScheme;

/// Creates a [State] for this [GoogleMap].
@override
State createState() => _GoogleMapState();
Expand Down Expand Up @@ -724,6 +733,7 @@ MapConfiguration _configurationFromMapWidget(GoogleMap map) {
trafficEnabled: map.trafficEnabled,
buildingsEnabled: map.buildingsEnabled,
cloudMapId: map.cloudMapId,
colorScheme: map.colorScheme,
// A null style in the widget means no style, which is expressed as '' in
// the configuration to distinguish from no change (null).
style: map.style ?? '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: google_maps_flutter
description: A Flutter plugin for integrating Google Maps in iOS and Android applications.
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
version: 2.14.0
version: 2.14.1

environment:
sdk: ^3.8.0
Expand Down Expand Up @@ -41,3 +41,8 @@ topics:
# The example deliberately includes limited-use secrets.
false_secrets:
- /example/web/index.html
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
google_maps_flutter_platform_interface: {path: ../../../packages/google_maps_flutter/google_maps_flutter_platform_interface}
google_maps_flutter_web: {path: ../../../packages/google_maps_flutter/google_maps_flutter_web}
Original file line number Diff line number Diff line change
Expand Up @@ -659,4 +659,39 @@ void main() {

expect(map.tileOverlaySets.length, 1);
});

testWidgets('Is default color scheme follow system', (
WidgetTester tester,
) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
child: GoogleMap(
initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0)),
),
),
);

final PlatformMapStateRecorder map = platform.lastCreatedMap;

expect(map.mapConfiguration.colorScheme, MapColorScheme.followSystem);
});

testWidgets('Can set color scheme to non-default', (
WidgetTester tester,
) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
child: GoogleMap(
initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0)),
colorScheme: MapColorScheme.light,
),
),
);

final PlatformMapStateRecorder map = platform.lastCreatedMap;

expect(map.mapConfiguration.colorScheme, MapColorScheme.light);
});
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.18.6

* Adds support for `colorScheme` for cloud-based maps styling brightness in web.

## 2.18.5

* Updates to Pigeon 26.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ flutter:
uses-material-design: true
assets:
- assets/
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
google_maps_flutter_platform_interface: {path: ../../../../packages/google_maps_flutter/google_maps_flutter_platform_interface}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: google_maps_flutter_android
description: Android implementation of the google_maps_flutter plugin.
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
version: 2.18.5
version: 2.18.6

environment:
sdk: ^3.9.0
Expand Down Expand Up @@ -37,3 +37,7 @@ topics:
- google-maps
- google-maps-flutter
- map
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
google_maps_flutter_platform_interface: {path: ../../../packages/google_maps_flutter/google_maps_flutter_platform_interface}
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.15.8

* Adds `colorScheme` support for web cloud-based maps styling brightness.

## 2.15.7

* Updates to Pigeon 26.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ flutter:
uses-material-design: true
assets:
- assets/
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
google_maps_flutter_platform_interface: {path: ../../../../../packages/google_maps_flutter/google_maps_flutter_platform_interface}
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ flutter:
uses-material-design: true
assets:
- assets/
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
google_maps_flutter_platform_interface: {path: ../../../../../packages/google_maps_flutter/google_maps_flutter_platform_interface}
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ dev_dependencies:

flutter:
uses-material-design: true
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
google_maps_flutter_platform_interface: {path: ../../../../../../packages/google_maps_flutter/google_maps_flutter_platform_interface}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: google_maps_flutter_ios
description: iOS implementation of the google_maps_flutter plugin.
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_ios
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
version: 2.15.7
version: 2.15.8

environment:
sdk: ^3.8.0
Expand Down Expand Up @@ -35,3 +35,7 @@ topics:
- google-maps
- google-maps-flutter
- map
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
google_maps_flutter_platform_interface: {path: ../../../packages/google_maps_flutter/google_maps_flutter_platform_interface}
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.14.2

* Adds support for `colorScheme` for cloud-based maps styling brightness in web.

## 2.14.1

* Replaces internal use of deprecated methods.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/// The color scheme of the map to be used with cloud styles
enum MapColorScheme {
/// The light color scheme for the map
light,

/// The dark color scheme for the map
dark,

/// The system default color scheme for the map
followSystem,
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class MapConfiguration {
String? cloudMapId,
this.style,
this.markerType,
this.colorScheme,
}) : mapId = mapId ?? cloudMapId;

/// This setting controls how the API handles gestures on the map. Web only.
Expand Down Expand Up @@ -152,6 +153,9 @@ class MapConfiguration {
@Deprecated('cloudMapId is deprecated. Use mapId instead.')
String? get cloudMapId => mapId;

/// Preferred color scheme for the map in web platform
final MapColorScheme? colorScheme;

/// Returns a new options object containing only the values of this instance
/// that are different from [other].
MapConfiguration diffFrom(MapConfiguration other) {
Expand Down Expand Up @@ -225,6 +229,7 @@ class MapConfiguration {
? buildingsEnabled
: null,
mapId: mapId != other.mapId ? mapId : null,
colorScheme: colorScheme != other.colorScheme ? colorScheme : null,
style: style != other.style ? style : null,
markerType: markerType != other.markerType ? markerType : null,
);
Expand Down Expand Up @@ -264,6 +269,7 @@ class MapConfiguration {
buildingsEnabled: diff.buildingsEnabled ?? buildingsEnabled,
mapId: diff.mapId ?? mapId,
style: diff.style ?? style,
colorScheme: diff.colorScheme ?? colorScheme,
markerType: diff.markerType ?? markerType,
);
}
Expand Down Expand Up @@ -293,6 +299,7 @@ class MapConfiguration {
trafficEnabled == null &&
buildingsEnabled == null &&
mapId == null &&
colorScheme == null &&
style == null &&
markerType == null;

Expand Down Expand Up @@ -329,6 +336,7 @@ class MapConfiguration {
buildingsEnabled == other.buildingsEnabled &&
mapId == other.mapId &&
style == other.style &&
colorScheme == other.colorScheme &&
markerType == other.markerType;
}

Expand Down Expand Up @@ -358,6 +366,7 @@ class MapConfiguration {
buildingsEnabled,
mapId,
style,
colorScheme,
markerType,
]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export 'heatmap.dart';
export 'heatmap_updates.dart';
export 'joint_type.dart';
export 'location.dart';
export 'map_color_scheme.dart';
export 'map_configuration.dart';
export 'map_objects.dart';
export 'map_widget_configuration.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/google_maps_f
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 2.14.1
version: 2.14.2

environment:
sdk: ^3.8.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 0.5.14+4

* Adds `colorScheme` support for web cloud-based maps styling brightness.
* Updates minimum supported SDK version to Flutter 3.32/Dart 3.8.

## 0.5.14+3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ flutter:
assets:
- assets/

# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
# Override the google_maps_flutter dependency on google_maps_flutter_web.
# TODO(ditman): Unwind the circular dependency. This will create problems
# if we need to make a breaking change to google_maps_flutter_web.
google_maps_flutter_web:
path: ../
google_maps_flutter: {path: ../../../../packages/google_maps_flutter/google_maps_flutter}
google_maps_flutter_platform_interface: {path: ../../../../packages/google_maps_flutter/google_maps_flutter_platform_interface}
google_maps_flutter_web: {path: ../}
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,35 @@ gmaps.MapOptions _configurationAndStyleToGmapsOptions(

options.mapId = configuration.mapId;

// Convert the color scheme, if any, and set it
final gmaps.ColorScheme? jsColorScheme = _gmapTypeColorSchemeForPluginColor(
configuration.colorScheme,
);
if (jsColorScheme != null) {
options.colorScheme = jsColorScheme;
}

return options;
}

/// Converts a [MapColorScheme] into a [gmaps.ColorScheme]
gmaps.ColorScheme? _gmapTypeColorSchemeForPluginColor(MapColorScheme? scheme) {
// Guard clause for null
if (scheme == null) {
return null;
}

// Map to gmaps.ColorScheme
switch (scheme) {
case MapColorScheme.dark:
return gmaps.ColorScheme.DARK;
case MapColorScheme.light:
return gmaps.ColorScheme.LIGHT;
case MapColorScheme.followSystem:
return gmaps.ColorScheme.FOLLOW_SYSTEM;
}
}
Comment on lines +146 to +161

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This function can be made more concise by using a switch expression, which is available in this version of Dart. This improves readability by reducing boilerplate.

gmaps.ColorScheme? _gmapTypeColorSchemeForPluginColor(MapColorScheme? scheme) {
  return switch (scheme) {
    MapColorScheme.dark => gmaps.ColorScheme.DARK,
    MapColorScheme.light => gmaps.ColorScheme.LIGHT,
    MapColorScheme.followSystem => gmaps.ColorScheme.FOLLOW_SYSTEM,
    null => null,
  };
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had considered this, but decided to match the style of the below _gmapTypeIDForPluginType function, which uses the older more verbose switch syntax.


gmaps.MapTypeId _gmapTypeIDForPluginType(MapType type) {
switch (type) {
case MapType.satellite:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: google_maps_flutter_web
description: Web platform implementation of google_maps_flutter
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
version: 0.5.14+3
version: 0.5.14+4

environment:
sdk: ^3.8.0
Expand Down Expand Up @@ -40,3 +40,7 @@ topics:
# The example deliberately includes limited-use secrets.
false_secrets:
- /example/web/index.html
# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
google_maps_flutter_platform_interface: {path: ../../../packages/google_maps_flutter/google_maps_flutter_platform_interface}