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
4 changes: 4 additions & 0 deletions packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.17.1

* Updates `colorScheme` doc comment to reflect Android and iOS support.

## 2.17.0

* Adds missing re-exports of classes related to advanced markers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,15 @@ class GoogleMap extends StatefulWidget {
/// may result in unexpected behavior.
final GoogleMapMarkerType markerType;

/// Color scheme for the cloud-style map. Web only.
/// Color scheme for the map.
///
/// The colorScheme option can only be set when the map is initialized;
/// setting this option after the map is created will have no effect.
/// On Android and iOS, the color scheme can be updated after the map is
/// created. On web, the value is applied only at map creation; later
/// changes have no effect.
///
/// The map must use a cloud-based map style (via [cloudMapId]) for the
/// color scheme to affect the base map tiles; otherwise the effect is
/// limited to map UI chrome.
///
/// See https://developers.google.com/maps/documentation/javascript/mapcolorscheme for more details.
final MapColorScheme? colorScheme;
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.17.0
version: 2.17.1

environment:
sdk: ^3.10.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.19.9

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

## 2.19.8

* Updates internal implementation to use Kotlin Pigeon.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,18 @@ static void interpretMapConfiguration(
if (style != null) {
sink.setMapStyle(style);
}
final PlatformMapColorScheme colorScheme = config.getColorScheme();
if (colorScheme != null) {
sink.setMapColorScheme(toMapColorScheme(colorScheme));
}
}

static int toMapColorScheme(@NonNull PlatformMapColorScheme colorScheme) {
return switch (colorScheme) {
case LIGHT -> com.google.android.gms.maps.model.MapColorScheme.LIGHT;
case DARK -> com.google.android.gms.maps.model.MapColorScheme.DARK;
case FOLLOW_SYSTEM -> com.google.android.gms.maps.model.MapColorScheme.FOLLOW_SYSTEM;
};
}

/** Set the options in the given object to marker options sink. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class GoogleMapBuilder implements GoogleMapOptionsSink {
private List<PlatformGroundOverlay> initialGroundOverlays;
private Rect padding = new Rect(0, 0, 0, 0);
private @Nullable String style;
private @Nullable Integer mapColorScheme;

GoogleMapController build(
int id,
Expand Down Expand Up @@ -59,6 +60,7 @@ GoogleMapController build(
controller.setInitialTileOverlays(initialTileOverlays);
controller.setInitialGroundOverlays(initialGroundOverlays);
controller.setMapStyle(style);
controller.setMapColorScheme(mapColorScheme);
return controller;
}

Expand Down Expand Up @@ -209,4 +211,9 @@ public void setInitialGroundOverlays(@NonNull List<PlatformGroundOverlay> initia
public void setMapStyle(@Nullable String style) {
this.style = style;
}

@Override
public void setMapColorScheme(@Nullable Integer colorScheme) {
this.mapColorScheme = colorScheme;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class GoogleMapController
private @Nullable List<PlatformGroundOverlay> initialGroundOverlays;
// Null except between initialization and onMapReady.
private @Nullable String initialMapStyle;
// Null except between initialization and onMapReady.
private @Nullable Integer initialMapColorScheme;
private boolean lastSetStyleSucceeded;
@VisibleForTesting List<Float> initialPadding;

Expand Down Expand Up @@ -245,6 +247,10 @@ public void onMapReady(@NonNull GoogleMap googleMap) {
updateMapStyle(initialMapStyle);
initialMapStyle = null;
}
if (initialMapColorScheme != null) {
googleMap.setMapColorScheme(initialMapColorScheme);
initialMapColorScheme = null;
}
}

// Returns the first TextureView found in the view hierarchy.
Expand Down Expand Up @@ -853,6 +859,17 @@ public void setMapStyle(@Nullable String style) {
}
}

public void setMapColorScheme(@Nullable Integer colorScheme) {
if (colorScheme == null) {
return;
}
if (googleMap == null) {
initialMapColorScheme = colorScheme;
} else {
googleMap.setMapColorScheme(colorScheme);
}
}

private boolean updateMapStyle(String style) {
// Dart passes an empty string to indicate that the style should be cleared.
final MapStyleOptions mapStyleOptions =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,6 @@ interface GoogleMapOptionsSink {
void setInitialGroundOverlays(@NonNull List<PlatformGroundOverlay> initialGroundOverlays);

void setMapStyle(@Nullable String style);

void setMapColorScheme(@Nullable Integer colorScheme);
}
Loading
Loading