Skip to content
Merged
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.0

* Adds support for disabling or moving the camera control button on web.
* Updates minimum supported SDK version to Flutter 3.29/Dart 3.7.

## 2.13.0
Expand Down Expand Up @@ -247,4 +248,4 @@

## 1.0.0 ... 1.0.0+5

* Development.
* Development.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class MapConfiguration {
/// as either a full configuration selection, or an update to an existing
/// configuration where only non-null values are updated.
const MapConfiguration({
this.webCameraControlPosition,
this.webCameraControlEnabled,
this.webGestureHandling,
this.compassEnabled,
this.mapToolbarEnabled,
Expand Down Expand Up @@ -47,6 +49,18 @@ class MapConfiguration {
/// See [WebGestureHandling] for more details.
final WebGestureHandling? webGestureHandling;

/// This setting controls how the API handles cameraControl button position on the map. Web only.
///
/// If null, the Google Maps API will use its default camera control position.
///
/// See [WebCameraControlPosition] for more details.
final WebCameraControlPosition? webCameraControlPosition;

/// This setting controls how the API handles cameraControl button on the map. Web only.
///
/// See https://developers.google.com/maps/documentation/javascript/controls for more details.
final bool? webCameraControlEnabled;

/// True if the compass UI should be shown.
final bool? compassEnabled;

Expand Down Expand Up @@ -142,6 +156,14 @@ class MapConfiguration {
/// that are different from [other].
MapConfiguration diffFrom(MapConfiguration other) {
return MapConfiguration(
webCameraControlPosition:
webCameraControlPosition != other.webCameraControlPosition
? webCameraControlPosition
: null,
webCameraControlEnabled:
webCameraControlEnabled != other.webCameraControlEnabled
? webCameraControlEnabled
: null,
webGestureHandling:
webGestureHandling != other.webGestureHandling
? webGestureHandling
Expand Down Expand Up @@ -218,6 +240,10 @@ class MapConfiguration {
/// replacing the previous values.
MapConfiguration applyDiff(MapConfiguration diff) {
return MapConfiguration(
webCameraControlPosition:
diff.webCameraControlPosition ?? webCameraControlPosition,
webCameraControlEnabled:
diff.webCameraControlEnabled ?? webCameraControlEnabled,
webGestureHandling: diff.webGestureHandling ?? webGestureHandling,
compassEnabled: diff.compassEnabled ?? compassEnabled,
mapToolbarEnabled: diff.mapToolbarEnabled ?? mapToolbarEnabled,
Expand Down Expand Up @@ -250,6 +276,8 @@ class MapConfiguration {

/// True if no options are set.
bool get isEmpty =>
webCameraControlPosition == null &&
webCameraControlEnabled == null &&
webGestureHandling == null &&
compassEnabled == null &&
mapToolbarEnabled == null &&
Expand Down Expand Up @@ -283,6 +311,8 @@ class MapConfiguration {
return false;
}
return other is MapConfiguration &&
webCameraControlPosition == other.webCameraControlPosition &&
webCameraControlEnabled == other.webCameraControlEnabled &&
webGestureHandling == other.webGestureHandling &&
compassEnabled == other.compassEnabled &&
mapToolbarEnabled == other.mapToolbarEnabled &&
Expand Down Expand Up @@ -311,6 +341,8 @@ class MapConfiguration {
@override
int get hashCode => Object.hashAll(<Object?>[
webGestureHandling,
webCameraControlPosition,
webCameraControlEnabled,
compassEnabled,
mapToolbarEnabled,
cameraTargetBounds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ export 'utils/marker.dart';
export 'utils/polygon.dart';
export 'utils/polyline.dart';
export 'utils/tile_overlay.dart';
export 'web_camera_control_position.dart';
export 'web_gesture_handling.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/// This setting controls how the API handles camera control button on the map.
///
/// See https://developers.google.com/maps/documentation/javascript/reference/control#ControlPosition
/// for more details.
enum WebCameraControlPosition {
/// Equivalent to BOTTOM_CENTER in both LTR and RTL.
blockEndInlineCenter,

/// Equivalent to BOTTOM_LEFT in LTR, or BOTTOM_RIGHT in RTL.
blockEndInlineStart,

/// Equivalent to BOTTOM_RIGHT in LTR, or BOTTOM_LEFT in RTL.
blockEndInlineEnd,

/// Equivalent to TOP_CENTER in both LTR and RTL.
blockStartInlineCenter,

/// Equivalent to TOP_LEFT in LTR, or TOP_RIGHT in RTL.
blockStartInlineStart,

/// Equivalent to TOP_RIGHT in LTR, or TOP_LEFT in RTL.
blockStartInlineEnd,

/// Elements are positioned in the center of the bottom row.
///
/// Consider using BLOCK_END_INLINE_CENTER instead.
bottomCenter,

/// Elements are positioned in the bottom left and flow towards the middle.
///
/// Elements are positioned to the right of the Google logo.
///
/// Consider using BLOCK_END_INLINE_START instead.
bottomLeft,

/// Elements are positioned in the bottom right and flow towards the middle.
///
/// Elements are positioned to the left of the copyrights.
///
/// Consider using BLOCK_END_INLINE_END instead.
bottomRight,

/// Equivalent to RIGHT_CENTER in LTR, or LEFT_CENTER in RTL.
inlineEndBlockCenter,

/// Equivalent to RIGHT_BOTTOM in LTR, or LEFT_BOTTOM in RTL.
inlineEndBlockEnd,

/// Equivalent to RIGHT_TOP in LTR, or LEFT_TOP in RTL.
inlineEndBlockStart,

/// Equivalent to LEFT_CENTER in LTR, or RIGHT_CENTER in RTL.
inlineStartBlockCenter,

/// Equivalent to LEFT_BOTTOM in LTR, or RIGHT_BOTTOM in RTL.
inlineStartBlockEnd,

/// Equivalent to LEFT_TOP in LTR, or RIGHT_TOP in RTL.
inlineStartBlockStart,

/// Elements are positioned on the left, above bottom-left elements,
/// and flow upwards.
///
/// Consider using INLINE_START_BLOCK_END instead.
leftBottom,

/// Elements are positioned in the center of the left side.
/// Consider using INLINE_START_BLOCK_CENTER instead.
leftCenter,

/// Elements are positioned on the left, below top-left elements,
/// and flow downwards.
///
/// Consider using INLINE_START_BLOCK_START instead.
leftTop,

/// Elements are positioned on the right, above bottom-right elements,
/// and flow upwards.
///
/// Consider using INLINE_END_BLOCK_END instead.
rightBottom,

/// Elements are positioned in the center of the right side.
///
/// Consider using INLINE_END_BLOCK_CENTER instead.
rightCenter,

/// Elements are positioned on the right, below top-right elements,
/// and flow downwards.
///
/// Consider using INLINE_END_BLOCK_START instead.
rightTop,

/// Elements are positioned in the center of the top row.
///
/// Consider using BLOCK_START_INLINE_CENTER instead.
topCenter,

/// Elements are positioned in the top left and flow towards the middle.
///
/// Consider using BLOCK_START_INLINE_START instead.
topLeft,

/// Elements are positioned in the top right and flow towards the middle.
///
/// Consider using BLOCK_START_INLINE_END instead.
topRight,
}
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.13.0
version: 2.14.0

environment:
sdk: ^3.7.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ void main() {
group('diffs', () {
// A options instance with every field set, to test diffs against.
final MapConfiguration diffBase = MapConfiguration(
webCameraControlPosition: WebCameraControlPosition.topRight,
webCameraControlEnabled: false,
webGestureHandling: WebGestureHandling.auto,
compassEnabled: false,
mapToolbarEnabled: false,
Expand Down Expand Up @@ -62,6 +64,8 @@ void main() {
expect(updated.liteModeEnabled, isNot(null));
expect(updated.padding, isNot(null));
expect(updated.trafficEnabled, isNot(null));
expect(updated.cloudMapId, null);
expect(updated.webCameraControlPosition, isNot(null));
expect(updated.mapId, null);
});

Expand All @@ -83,6 +87,45 @@ void main() {
expect(empty.hashCode, isNot(diff.hashCode));
});

test('handle webCameraControlPosition', () async {
const MapConfiguration diff = MapConfiguration(
webCameraControlPosition: WebCameraControlPosition.blockEndInlineEnd,
);

const MapConfiguration empty = MapConfiguration();
final MapConfiguration updated = diffBase.applyDiff(diff);

// A diff applied to empty options should be the diff itself.
expect(empty.applyDiff(diff), diff);
// The diff from empty options should be the diff itself.
expect(diff.diffFrom(empty), diff);
// A diff applied to non-empty options should update that field.
expect(
updated.webCameraControlPosition,
WebCameraControlPosition.blockEndInlineEnd,
);
// The hash code should change.
expect(empty.hashCode, isNot(diff.hashCode));
});

test('handle webCameraControlEnabled', () async {
const MapConfiguration diff = MapConfiguration(
webCameraControlEnabled: true,
);

const MapConfiguration empty = MapConfiguration();
final MapConfiguration updated = diffBase.applyDiff(diff);

// A diff applied to empty options should be the diff itself.
expect(empty.applyDiff(diff), diff);
// The diff from empty options should be the diff itself.
expect(diff.diffFrom(empty), diff);
// A diff applied to non-empty options should update that field.
expect(updated.webCameraControlEnabled, true);
// The hash code should change.
expect(empty.hashCode, isNot(diff.hashCode));
});

test('handle compassEnabled', () async {
const MapConfiguration diff = MapConfiguration(compassEnabled: true);

Expand Down Expand Up @@ -470,6 +513,22 @@ void main() {
expect(nullOptions.isEmpty, true);
});

test('is false with webCameraControlEnabled', () async {
const MapConfiguration diff = MapConfiguration(
webCameraControlEnabled: true,
);

expect(diff.isEmpty, false);
});

test('is false with webCameraControlPosition', () async {
const MapConfiguration diff = MapConfiguration(
webCameraControlPosition: WebCameraControlPosition.blockEndInlineCenter,
);

expect(diff.isEmpty, false);
});

test('is false with compassEnabled', () async {
const MapConfiguration diff = MapConfiguration(compassEnabled: true);

Expand Down