mirror of
https://github.com/flutter/packages.git
synced 2025-06-30 23:03:11 +08:00
[google_maps_flutter_platform_interface] Add support for cloud-based map styling (#4141)
This PR is sub-PR splitted out from the https://github.com/flutter/packages/pull/3682 containing only the platform_interface package changes. Related to issue https://github.com/flutter/flutter/issues/67631
This commit is contained in:
@ -1,3 +1,7 @@
|
|||||||
|
## 2.3.0
|
||||||
|
|
||||||
|
* Adds a `cloudMapId` parameter to support cloud-based map styling.
|
||||||
|
|
||||||
## 2.2.7
|
## 2.2.7
|
||||||
|
|
||||||
* Removes obsolete null checks on non-nullable values.
|
* Removes obsolete null checks on non-nullable values.
|
||||||
|
@ -33,6 +33,7 @@ class MapConfiguration {
|
|||||||
this.indoorViewEnabled,
|
this.indoorViewEnabled,
|
||||||
this.trafficEnabled,
|
this.trafficEnabled,
|
||||||
this.buildingsEnabled,
|
this.buildingsEnabled,
|
||||||
|
this.cloudMapId,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// True if the compass UI should be shown.
|
/// True if the compass UI should be shown.
|
||||||
@ -90,6 +91,12 @@ class MapConfiguration {
|
|||||||
/// True if 3D building display should be enabled.
|
/// True if 3D building display should be enabled.
|
||||||
final bool? buildingsEnabled;
|
final bool? buildingsEnabled;
|
||||||
|
|
||||||
|
/// Identifier that's associated with a specific cloud-based map style.
|
||||||
|
///
|
||||||
|
/// See https://developers.google.com/maps/documentation/get-map-id
|
||||||
|
/// for more details.
|
||||||
|
final String? cloudMapId;
|
||||||
|
|
||||||
/// Returns a new options object containing only the values of this instance
|
/// Returns a new options object containing only the values of this instance
|
||||||
/// that are different from [other].
|
/// that are different from [other].
|
||||||
MapConfiguration diffFrom(MapConfiguration other) {
|
MapConfiguration diffFrom(MapConfiguration other) {
|
||||||
@ -143,6 +150,7 @@ class MapConfiguration {
|
|||||||
trafficEnabled != other.trafficEnabled ? trafficEnabled : null,
|
trafficEnabled != other.trafficEnabled ? trafficEnabled : null,
|
||||||
buildingsEnabled:
|
buildingsEnabled:
|
||||||
buildingsEnabled != other.buildingsEnabled ? buildingsEnabled : null,
|
buildingsEnabled != other.buildingsEnabled ? buildingsEnabled : null,
|
||||||
|
cloudMapId: cloudMapId != other.cloudMapId ? cloudMapId : null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,6 +179,7 @@ class MapConfiguration {
|
|||||||
indoorViewEnabled: diff.indoorViewEnabled ?? indoorViewEnabled,
|
indoorViewEnabled: diff.indoorViewEnabled ?? indoorViewEnabled,
|
||||||
trafficEnabled: diff.trafficEnabled ?? trafficEnabled,
|
trafficEnabled: diff.trafficEnabled ?? trafficEnabled,
|
||||||
buildingsEnabled: diff.buildingsEnabled ?? buildingsEnabled,
|
buildingsEnabled: diff.buildingsEnabled ?? buildingsEnabled,
|
||||||
|
cloudMapId: diff.cloudMapId ?? cloudMapId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +202,8 @@ class MapConfiguration {
|
|||||||
padding == null &&
|
padding == null &&
|
||||||
indoorViewEnabled == null &&
|
indoorViewEnabled == null &&
|
||||||
trafficEnabled == null &&
|
trafficEnabled == null &&
|
||||||
buildingsEnabled == null;
|
buildingsEnabled == null &&
|
||||||
|
cloudMapId == null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
@ -221,7 +231,8 @@ class MapConfiguration {
|
|||||||
padding == other.padding &&
|
padding == other.padding &&
|
||||||
indoorViewEnabled == other.indoorViewEnabled &&
|
indoorViewEnabled == other.indoorViewEnabled &&
|
||||||
trafficEnabled == other.trafficEnabled &&
|
trafficEnabled == other.trafficEnabled &&
|
||||||
buildingsEnabled == other.buildingsEnabled;
|
buildingsEnabled == other.buildingsEnabled &&
|
||||||
|
cloudMapId == other.cloudMapId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -244,5 +255,6 @@ class MapConfiguration {
|
|||||||
indoorViewEnabled,
|
indoorViewEnabled,
|
||||||
trafficEnabled,
|
trafficEnabled,
|
||||||
buildingsEnabled,
|
buildingsEnabled,
|
||||||
|
cloudMapId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -58,5 +58,6 @@ Map<String, Object> jsonForMapConfiguration(MapConfiguration config) {
|
|||||||
if (config.trafficEnabled != null) 'trafficEnabled': config.trafficEnabled!,
|
if (config.trafficEnabled != null) 'trafficEnabled': config.trafficEnabled!,
|
||||||
if (config.buildingsEnabled != null)
|
if (config.buildingsEnabled != null)
|
||||||
'buildingsEnabled': config.buildingsEnabled!,
|
'buildingsEnabled': config.buildingsEnabled!,
|
||||||
|
if (config.cloudMapId != null) 'cloudMapId': config.cloudMapId!,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -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
|
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
|
# 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
|
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
|
||||||
version: 2.2.7
|
version: 2.3.0
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.18.0 <4.0.0"
|
sdk: ">=2.18.0 <4.0.0"
|
||||||
|
@ -6,6 +6,8 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
|
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
|
||||||
|
|
||||||
|
const String _kCloudMapId = '000000000000000'; // Dummy map ID.
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('diffs', () {
|
group('diffs', () {
|
||||||
// A options instance with every field set, to test diffs against.
|
// A options instance with every field set, to test diffs against.
|
||||||
@ -53,6 +55,7 @@ void main() {
|
|||||||
expect(updated.liteModeEnabled, isNot(null));
|
expect(updated.liteModeEnabled, isNot(null));
|
||||||
expect(updated.padding, isNot(null));
|
expect(updated.padding, isNot(null));
|
||||||
expect(updated.trafficEnabled, isNot(null));
|
expect(updated.trafficEnabled, isNot(null));
|
||||||
|
expect(updated.cloudMapId, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('handle compassEnabled', () async {
|
test('handle compassEnabled', () async {
|
||||||
@ -281,6 +284,18 @@ void main() {
|
|||||||
// A diff applied to non-empty options should update that field.
|
// A diff applied to non-empty options should update that field.
|
||||||
expect(updated.buildingsEnabled, true);
|
expect(updated.buildingsEnabled, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('handle cloudMapId', () async {
|
||||||
|
const MapConfiguration diff = MapConfiguration(cloudMapId: _kCloudMapId);
|
||||||
|
|
||||||
|
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);
|
||||||
|
// A diff applied to non-empty options should update that field.
|
||||||
|
expect(updated.cloudMapId, _kCloudMapId);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group('isEmpty', () {
|
group('isEmpty', () {
|
||||||
@ -408,5 +423,11 @@ void main() {
|
|||||||
|
|
||||||
expect(diff.isEmpty, false);
|
expect(diff.isEmpty, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('is false with cloudMapId', () async {
|
||||||
|
const MapConfiguration diff = MapConfiguration(cloudMapId: _kCloudMapId);
|
||||||
|
|
||||||
|
expect(diff.isEmpty, false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
|
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
|
||||||
import 'package:google_maps_flutter_platform_interface/src/types/utils/map_configuration_serialization.dart';
|
import 'package:google_maps_flutter_platform_interface/src/types/utils/map_configuration_serialization.dart';
|
||||||
|
|
||||||
|
const String _kCloudMapId = '000000000000000'; // Dummy map ID.
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test('empty serialization', () async {
|
test('empty serialization', () async {
|
||||||
const MapConfiguration config = MapConfiguration();
|
const MapConfiguration config = MapConfiguration();
|
||||||
@ -18,26 +20,26 @@ void main() {
|
|||||||
|
|
||||||
test('complete serialization', () async {
|
test('complete serialization', () async {
|
||||||
final MapConfiguration config = MapConfiguration(
|
final MapConfiguration config = MapConfiguration(
|
||||||
compassEnabled: false,
|
compassEnabled: false,
|
||||||
mapToolbarEnabled: false,
|
mapToolbarEnabled: false,
|
||||||
cameraTargetBounds: CameraTargetBounds(LatLngBounds(
|
cameraTargetBounds: CameraTargetBounds(LatLngBounds(
|
||||||
northeast: const LatLng(30, 20), southwest: const LatLng(10, 40))),
|
northeast: const LatLng(30, 20), southwest: const LatLng(10, 40))),
|
||||||
mapType: MapType.normal,
|
mapType: MapType.normal,
|
||||||
minMaxZoomPreference: const MinMaxZoomPreference(1.0, 10.0),
|
minMaxZoomPreference: const MinMaxZoomPreference(1.0, 10.0),
|
||||||
rotateGesturesEnabled: false,
|
rotateGesturesEnabled: false,
|
||||||
scrollGesturesEnabled: false,
|
scrollGesturesEnabled: false,
|
||||||
tiltGesturesEnabled: false,
|
tiltGesturesEnabled: false,
|
||||||
trackCameraPosition: false,
|
trackCameraPosition: false,
|
||||||
zoomControlsEnabled: false,
|
zoomControlsEnabled: false,
|
||||||
zoomGesturesEnabled: false,
|
zoomGesturesEnabled: false,
|
||||||
liteModeEnabled: false,
|
liteModeEnabled: false,
|
||||||
myLocationEnabled: false,
|
myLocationEnabled: false,
|
||||||
myLocationButtonEnabled: false,
|
myLocationButtonEnabled: false,
|
||||||
padding: const EdgeInsets.all(5.0),
|
padding: const EdgeInsets.all(5.0),
|
||||||
indoorViewEnabled: false,
|
indoorViewEnabled: false,
|
||||||
trafficEnabled: false,
|
trafficEnabled: false,
|
||||||
buildingsEnabled: false,
|
buildingsEnabled: false,
|
||||||
);
|
cloudMapId: _kCloudMapId);
|
||||||
|
|
||||||
final Map<String, Object> json = jsonForMapConfiguration(config);
|
final Map<String, Object> json = jsonForMapConfiguration(config);
|
||||||
|
|
||||||
@ -69,7 +71,8 @@ void main() {
|
|||||||
'padding': <double>[5.0, 5.0, 5.0, 5.0],
|
'padding': <double>[5.0, 5.0, 5.0, 5.0],
|
||||||
'indoorEnabled': false,
|
'indoorEnabled': false,
|
||||||
'trafficEnabled': false,
|
'trafficEnabled': false,
|
||||||
'buildingsEnabled': false
|
'buildingsEnabled': false,
|
||||||
|
'cloudMapId': _kCloudMapId
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user