From 42cbd75b6ae51c5c0e4e5428abc1edcfc21cbfb7 Mon Sep 17 00:00:00 2001 From: Joonas Kerttula Date: Thu, 8 Dec 2022 11:17:16 +0200 Subject: [PATCH 1/6] [google_maps_flutter] cloud-based map id support --- .../google_maps_flutter/CHANGELOG.md | 6 +- .../integration_test/google_maps_test.dart | 27 +++ .../google_maps_flutter/example/lib/main.dart | 2 + .../example/lib/map_map_id.dart | 164 ++++++++++++++++++ .../google_maps_flutter/example/pubspec.yaml | 13 ++ .../lib/src/google_map.dart | 8 + .../google_maps_flutter/pubspec.yaml | 13 +- .../google_maps_flutter_android/CHANGELOG.md | 3 +- .../flutter/plugins/googlemaps/Convert.java | 4 + .../plugins/googlemaps/GoogleMapBuilder.java | 5 + .../googlemaps/GoogleMapController.java | 5 + .../googlemaps/GoogleMapOptionsSink.java | 2 + .../integration_test/google_maps_tests.dart | 27 +++ .../example/lib/example_google_map.dart | 8 + .../example/lib/main.dart | 2 + .../example/lib/map_map_id.dart | 158 +++++++++++++++++ .../example/pubspec.yaml | 8 + .../lib/src/google_maps_flutter_android.dart | 1 + .../google_maps_flutter_android/pubspec.yaml | 8 +- .../google_maps_flutter_ios/CHANGELOG.md | 6 +- .../integration_test/google_maps_test.dart | 14 ++ .../example/lib/example_google_map.dart | 8 + .../example/lib/main.dart | 2 + .../example/lib/map_map_id.dart | 115 ++++++++++++ .../example/pubspec.yaml | 8 + .../ios/Classes/GoogleMapController.m | 14 +- .../lib/src/google_maps_flutter_ios.dart | 1 + .../google_maps_flutter_ios/pubspec.yaml | 8 +- .../CHANGELOG.md | 3 +- .../lib/src/types/map_configuration.dart | 16 +- .../pubspec.yaml | 2 +- .../google_maps_flutter_web/CHANGELOG.md | 3 +- .../google_maps_controller_test.dart | 3 + .../example/pubspec.yaml | 10 ++ .../lib/src/convert.dart | 8 + .../lib/src/google_maps_controller.dart | 1 + .../google_maps_flutter_web/pubspec.yaml | 8 +- 37 files changed, 680 insertions(+), 14 deletions(-) create mode 100644 packages/google_maps_flutter/google_maps_flutter/example/lib/map_map_id.dart create mode 100644 packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_map_id.dart create mode 100644 packages/google_maps_flutter/google_maps_flutter_ios/example/lib/map_map_id.dart diff --git a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md index bab8412142d9..bb5aa5985f4e 100644 --- a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md @@ -1,4 +1,8 @@ -## NEXT +## 2.4.0 + +* Adds implementation for `cloudMapId` parameter to support cloud-based maps styling. + +## 2.3.0 * Updates minimum Flutter version to 3.0. diff --git a/packages/google_maps_flutter/google_maps_flutter/example/integration_test/google_maps_test.dart b/packages/google_maps_flutter/google_maps_flutter/example/integration_test/google_maps_test.dart index 38a02ea0d8f1..b5ab166f4a61 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/integration_test/google_maps_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/integration_test/google_maps_test.dart @@ -17,6 +17,7 @@ const LatLng _kInitialMapCenter = LatLng(0, 0); const double _kInitialZoomLevel = 5; const CameraPosition _kInitialCameraPosition = CameraPosition(target: _kInitialMapCenter, zoom: _kInitialZoomLevel); +const String _kCloudMapId = '8e0a97af9386fef'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); @@ -1161,6 +1162,32 @@ void main() { expect(tileOverlayInfo1, isNull); }, ); + + testWidgets( + 'testCloudMapId', + (WidgetTester tester) async { + final Completer mapIdCompleter = Completer(); + final Key key = GlobalKey(); + + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: GoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (GoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + cloudMapId: _kCloudMapId, + ), + ), + ); + + // Await mapIdCompleter to finish to make sure map can be created with styledMapId + // Styled map + await mapIdCompleter.future; + }, + ); } class _DebugTileProvider implements TileProvider { diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/main.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/main.dart index 60d4fdd95dcf..19a798ecc0ee 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/main.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/main.dart @@ -10,6 +10,7 @@ import 'animate_camera.dart'; import 'lite_mode.dart'; import 'map_click.dart'; import 'map_coordinates.dart'; +import 'map_map_id.dart'; import 'map_ui.dart'; import 'marker_icons.dart'; import 'move_camera.dart'; @@ -39,6 +40,7 @@ final List _allPages = [ const SnapshotPage(), const LiteModePage(), const TileOverlayPage(), + const MapIdPage(), ]; /// MapsDemo is the Main Application. diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/map_map_id.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/map_map_id.dart new file mode 100644 index 000000000000..ea5db0927655 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/map_map_id.dart @@ -0,0 +1,164 @@ +// 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. + +// ignore_for_file: public_member_api_docs + +import 'dart:async'; +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:google_maps_flutter_android/google_maps_flutter_android.dart'; +import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; +import 'page.dart'; + +class MapIdPage extends GoogleMapExampleAppPage { + const MapIdPage({Key? key}) + : super(const Icon(Icons.map), 'Cloud-based maps styling', key: key); + + @override + Widget build(BuildContext context) { + return const MapIdBody(); + } +} + +class MapIdBody extends StatefulWidget { + const MapIdBody({Key? key}) : super(key: key); + + @override + State createState() => MapIdBodyState(); +} + +const LatLng _kMapCenter = LatLng(52.4478, -3.5402); + +class MapIdBodyState extends State { + GoogleMapController? controller; + + Key _key = const Key('mapId#'); + String? _mapId; + final TextEditingController _mapIdController = TextEditingController(); + AndroidMapRenderer? _initializedRenderer; + + @override + void initState() { + _initializeMapRenderer() + .then((AndroidMapRenderer? initializedRenderer) => setState(() { + _initializedRenderer = initializedRenderer; + })); + super.initState(); + } + + String _getInitializedsRendererType() { + switch (_initializedRenderer) { + case AndroidMapRenderer.latest: + return 'latest'; + case AndroidMapRenderer.legacy: + return 'legacy'; + default: + return 'initializing'; + } + } + + void _setMapId() { + setState(() { + _mapId = _mapIdController.text; + + // Change key to initialize new map instance for new mapId. + _key = Key(_mapId ?? 'mapId#'); + }); + } + + @override + Widget build(BuildContext context) { + final GoogleMap googleMap = GoogleMap( + onMapCreated: _onMapCreated, + initialCameraPosition: const CameraPosition( + target: _kMapCenter, + zoom: 7.0, + ), + key: _key, + cloudMapId: _mapId); + + final List columnChildren = [ + Padding( + padding: const EdgeInsets.all(10.0), + child: Center( + child: SizedBox( + width: 300.0, + height: 200.0, + child: googleMap, + ), + ), + ), + Padding( + padding: const EdgeInsets.all(10.0), + child: TextField( + controller: _mapIdController, + decoration: const InputDecoration( + hintText: 'Map Id', + ), + )), + Padding( + padding: const EdgeInsets.all(10.0), + child: ElevatedButton( + onPressed: () => _setMapId(), + child: const Text( + 'Press to use specified map Id', + ), + )), + if (Platform.isAndroid) + Padding( + padding: const EdgeInsets.all(10.0), + child: Text( + 'On Android, Cloud-based maps styling only works with "latest" renderer.\n\n' + 'Current initialized renderer is "${_getInitializedsRendererType()}".'), + ), + if (Platform.isIOS) + const Padding( + padding: EdgeInsets.all(10.0), + child: + Text('On iOS, cloud based map styling works only if iOS platform ' + 'version 12 or above is targeted in project Podfile. ' + "Run command 'pod update GoogleMaps' to update plugin"), + ) + ]; + + return Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: columnChildren, + ); + } + + @override + void dispose() { + _mapIdController.dispose(); + super.dispose(); + } + + void _onMapCreated(GoogleMapController controllerParam) { + setState(() { + controller = controllerParam; + }); + } +} + +Completer? _initializedRendererCompleter; +Future _initializeMapRenderer() async { + if (_initializedRendererCompleter != null) { + return _initializedRendererCompleter!.future; + } + + _initializedRendererCompleter = Completer(); + final GoogleMapsFlutterPlatform mapsImplementation = + GoogleMapsFlutterPlatform.instance; + if (mapsImplementation is GoogleMapsFlutterAndroid) { + mapsImplementation.initializeWithRenderer(AndroidMapRenderer.latest).then( + (AndroidMapRenderer initializedRenderer) => + _initializedRendererCompleter!.complete(initializedRenderer)); + } else { + _initializedRendererCompleter!.complete(null); + } + + return _initializedRendererCompleter!.future; +} diff --git a/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml index 5813d42e617e..08f598f4e640 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml @@ -19,6 +19,7 @@ dependencies: # the parent directory to use the current plugin's version. path: ../ google_maps_flutter_android: ^2.1.10 + google_maps_flutter_ios: ^2.1.10 google_maps_flutter_platform_interface: ^2.2.1 dev_dependencies: @@ -35,3 +36,15 @@ flutter: uses-material-design: true assets: - assets/ + + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + google_maps_flutter: + path: ../../../google_maps_flutter/google_maps_flutter + google_maps_flutter_android: + path: ../../../google_maps_flutter/google_maps_flutter_android + google_maps_flutter_ios: + path: ../../../google_maps_flutter/google_maps_flutter_ios + google_maps_flutter_platform_interface: + path: ../../../google_maps_flutter/google_maps_flutter_platform_interface diff --git a/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart b/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart index 1f7871068cab..c03404b21eeb 100644 --- a/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart +++ b/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart @@ -123,6 +123,7 @@ class GoogleMap extends StatefulWidget { this.onCameraIdle, this.onTap, this.onLongPress, + this.cloudMapId, }) : assert(initialCameraPosition != null), super(key: key); @@ -283,6 +284,12 @@ class GoogleMap extends StatefulWidget { /// were not claimed by any other gesture recognizer. final Set> gestureRecognizers; + /// Identifier that's associated with a specific cloud bases map style. + /// + /// See https://developers.google.com/maps/documentation/get-map-id + /// for more details. + final String? cloudMapId; + /// Creates a [State] for this [GoogleMap]. @override State createState() => _GoogleMapState(); @@ -553,5 +560,6 @@ MapConfiguration _configurationFromMapWidget(GoogleMap map) { indoorViewEnabled: map.indoorViewEnabled, trafficEnabled: map.trafficEnabled, buildingsEnabled: map.buildingsEnabled, + cloudMapId: map.cloudMapId, ); } diff --git a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml index 0771314b9e44..52f74cbdfe53 100644 --- a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml @@ -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/plugins/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.2.3 +version: 2.4.0 environment: sdk: ">=2.14.0 <3.0.0" @@ -20,7 +20,6 @@ dependencies: flutter: sdk: flutter google_maps_flutter_android: ^2.1.10 - google_maps_flutter_ios: ^2.1.10 google_maps_flutter_platform_interface: ^2.2.1 dev_dependencies: @@ -28,3 +27,13 @@ dev_dependencies: sdk: flutter plugin_platform_interface: ^2.0.0 stream_transform: ^2.0.0 + + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + google_maps_flutter_android: + path: ../../google_maps_flutter/google_maps_flutter_android + google_maps_flutter_ios: + path: ../../google_maps_flutter/google_maps_flutter_ios + google_maps_flutter_platform_interface: + path: ../../google_maps_flutter/google_maps_flutter_platform_interface diff --git a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md index 6e596c135f38..73740cf9ba50 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 2.5.0 +* Adds implementation for `cloudMapId` parameter to support cloud-based map styling. * Updates minimum Flutter version to 3.0. ## 2.4.3 diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java index 72c6959fe55e..ecd85a8633ee 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java @@ -376,6 +376,10 @@ static void interpretGoogleMapOptions(Object o, GoogleMapOptionsSink sink) { if (buildingsEnabled != null) { sink.setBuildingsEnabled(toBoolean(buildingsEnabled)); } + final Object cloudMapId = data.get("cloudMapId"); + if (buildingsEnabled != null) { + sink.setMapId(toString(cloudMapId)); + } } /** Returns the dartMarkerId of the interpreted marker. */ diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapBuilder.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapBuilder.java index ad5179a69a45..fae03c050c7a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapBuilder.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapBuilder.java @@ -174,4 +174,9 @@ public void setInitialCircles(Object initialCircles) { public void setInitialTileOverlays(List> initialTileOverlays) { this.initialTileOverlays = initialTileOverlays; } + + @Override + public void setMapId(String mapId) { + options.mapId(mapId); + } } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java index 66d3e283b8df..0046300129f9 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java @@ -848,6 +848,11 @@ public void setInitialTileOverlays(List> initialTileOverlays) { } } + @Override + public void setMapId(String mapId) { + Log.e(TAG, "Cannot change MapId after map is initialized."); + } + private void updateInitialTileOverlays() { tileOverlaysController.addTileOverlays(initialTileOverlays); } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapOptionsSink.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapOptionsSink.java index 17f0d970a4ef..e3308a8b3350 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapOptionsSink.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapOptionsSink.java @@ -55,4 +55,6 @@ interface GoogleMapOptionsSink { void setInitialCircles(Object initialCircles); void setInitialTileOverlays(List> initialTileOverlays); + + void setMapId(String mapId); } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_tests.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_tests.dart index bd72b7ba52d2..584b5eaa069c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_tests.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_tests.dart @@ -17,6 +17,7 @@ const LatLng _kInitialMapCenter = LatLng(0, 0); const double _kInitialZoomLevel = 5; const CameraPosition _kInitialCameraPosition = CameraPosition(target: _kInitialMapCenter, zoom: _kInitialZoomLevel); +const String _kCloudMapId = '8e0a97af9386fef'; void googleMapsTests() { GoogleMapsFlutterPlatform.instance.enableDebugInspection(); @@ -1178,6 +1179,32 @@ void googleMapsTests() { expect(tileOverlayInfo1, isNull); }, ); + + testWidgets( + 'testCloudMapId', + (WidgetTester tester) async { + final Completer mapIdCompleter = Completer(); + final Key key = GlobalKey(); + + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + cloudMapId: _kCloudMapId, + ), + ), + ); + + // Await mapIdCompleter to finish to make sure map can be created with styledMapId + // Styled map + await mapIdCompleter.future; + }, + ); } class _DebugTileProvider implements TileProvider { diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/example_google_map.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/example_google_map.dart index 1c1261cb5b82..5357b30f183e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/example_google_map.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/example_google_map.dart @@ -247,6 +247,7 @@ class ExampleGoogleMap extends StatefulWidget { this.onCameraIdle, this.onTap, this.onLongPress, + this.cloudMapId, }) : super(key: key); /// Callback method for when the map is ready to be used. @@ -349,6 +350,12 @@ class ExampleGoogleMap extends StatefulWidget { /// Which gestures should be consumed by the map. final Set> gestureRecognizers; + /// Identifier that's associated with a specific cloud bases map style. + /// + /// See https://developers.google.com/maps/documentation/get-map-id + /// for more details. + final String? cloudMapId; + /// Creates a [State] for this [ExampleGoogleMap]. @override State createState() => _ExampleGoogleMapState(); @@ -534,5 +541,6 @@ MapConfiguration _configurationFromMapWidget(ExampleGoogleMap map) { indoorViewEnabled: map.indoorViewEnabled, trafficEnabled: map.trafficEnabled, buildingsEnabled: map.buildingsEnabled, + cloudMapId: map.cloudMapId, ); } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/main.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/main.dart index 4adec524f87b..d502870bcb29 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/main.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/main.dart @@ -10,6 +10,7 @@ import 'animate_camera.dart'; import 'lite_mode.dart'; import 'map_click.dart'; import 'map_coordinates.dart'; +import 'map_map_id.dart'; import 'map_ui.dart'; import 'marker_icons.dart'; import 'move_camera.dart'; @@ -39,6 +40,7 @@ final List _allPages = [ const SnapshotPage(), const LiteModePage(), const TileOverlayPage(), + const MapIdPage(), ]; /// MapsDemo is the Main Application. diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_map_id.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_map_id.dart new file mode 100644 index 000000000000..d9ef73aff1fe --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_map_id.dart @@ -0,0 +1,158 @@ +// 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. + +// ignore_for_file: public_member_api_docs + +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:google_maps_flutter_android/google_maps_flutter_android.dart'; +import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; + +import 'example_google_map.dart'; +import 'page.dart'; + +class MapIdPage extends GoogleMapExampleAppPage { + const MapIdPage({Key? key}) + : super(const Icon(Icons.map), 'Cloud-based maps styling', key: key); + + @override + Widget build(BuildContext context) { + return const MapIdBody(); + } +} + +class MapIdBody extends StatefulWidget { + const MapIdBody({Key? key}) : super(key: key); + + @override + State createState() => MapIdBodyState(); +} + +const LatLng _kMapCenter = LatLng(52.4478, -3.5402); + +class MapIdBodyState extends State { + ExampleGoogleMapController? controller; + + Key _key = const Key('mapId#'); + String? _mapId; + final TextEditingController _mapIdController = TextEditingController(); + AndroidMapRenderer? _initializedRenderer; + + @override + void initState() { + _initializeMapRenderer() + .then((AndroidMapRenderer? initializedRenderer) => setState(() { + _initializedRenderer = initializedRenderer; + })); + super.initState(); + } + + String _getInitializedsRendererType() { + switch (_initializedRenderer) { + case AndroidMapRenderer.latest: + return 'latest'; + case AndroidMapRenderer.legacy: + return 'legacy'; + default: + return 'initializing'; + } + } + + void _setMapId() { + setState(() { + _mapId = _mapIdController.text; + + // Change key to initialize new map instance for new mapId. + _key = Key(_mapId ?? 'mapId#'); + }); + } + + @override + Widget build(BuildContext context) { + final ExampleGoogleMap googleMap = ExampleGoogleMap( + onMapCreated: _onMapCreated, + initialCameraPosition: const CameraPosition( + target: _kMapCenter, + zoom: 7.0, + ), + key: _key, + cloudMapId: _mapId, + ); + + final List columnChildren = [ + Padding( + padding: const EdgeInsets.all(10.0), + child: Center( + child: SizedBox( + width: 300.0, + height: 200.0, + child: googleMap, + ), + ), + ), + Padding( + padding: const EdgeInsets.all(10.0), + child: TextField( + controller: _mapIdController, + decoration: const InputDecoration( + hintText: 'Map Id', + ), + )), + Padding( + padding: const EdgeInsets.all(10.0), + child: ElevatedButton( + onPressed: () => _setMapId(), + child: const Text( + 'Press to use specified map Id', + ), + )), + Padding( + padding: const EdgeInsets.all(10.0), + child: Text( + 'On Android, Cloud-based maps styling only works with "latest" renderer.\n\n' + 'Current initialized renderer is "${_getInitializedsRendererType()}".'), + ), + ]; + + return Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: columnChildren, + ); + } + + @override + void dispose() { + _mapIdController.dispose(); + super.dispose(); + } + + void _onMapCreated(ExampleGoogleMapController controllerParam) { + setState(() { + controller = controllerParam; + }); + } +} + +Completer? _initializedRendererCompleter; +Future _initializeMapRenderer() async { + // Map renderer can be requested only once. + // Returns existing copleter future for serial requests. + if (_initializedRendererCompleter != null) { + return _initializedRendererCompleter!.future; + } + + _initializedRendererCompleter = Completer(); + final GoogleMapsFlutterPlatform mapsImplementation = + GoogleMapsFlutterPlatform.instance; + if (mapsImplementation is GoogleMapsFlutterAndroid) { + mapsImplementation.initializeWithRenderer(AndroidMapRenderer.latest).then( + (AndroidMapRenderer initializedRenderer) => + _initializedRendererCompleter!.complete(initializedRenderer)); + } else { + _initializedRendererCompleter!.complete(null); + } + + return _initializedRendererCompleter!.future; +} diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_android/example/pubspec.yaml index aa29fa99a97b..813cfe362718 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/pubspec.yaml @@ -34,3 +34,11 @@ flutter: uses-material-design: true assets: - assets/ + + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + google_maps_flutter_android: + path: ../../../google_maps_flutter/google_maps_flutter_android + google_maps_flutter_platform_interface: + path: ../../../google_maps_flutter/google_maps_flutter_platform_interface diff --git a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart index 0461b4cf71bc..445331b5e086 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart @@ -751,6 +751,7 @@ Map _jsonForMapConfiguration(MapConfiguration config) { if (config.trafficEnabled != null) 'trafficEnabled': config.trafficEnabled!, if (config.buildingsEnabled != null) 'buildingsEnabled': config.buildingsEnabled!, + if (config.cloudMapId != null) 'cloudMapId': config.cloudMapId!, }; } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml index d67e85f15e9a..f3ca68ad942e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter_android description: Android implementation of the google_maps_flutter plugin. repository: https://github.com/flutter/plugins/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.4.3 +version: 2.5.0 environment: sdk: ">=2.14.0 <3.0.0" @@ -29,3 +29,9 @@ dev_dependencies: flutter_test: sdk: flutter plugin_platform_interface: ^2.0.0 + + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + google_maps_flutter_platform_interface: + path: ../../google_maps_flutter/google_maps_flutter_platform_interface diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md index a65523f426c1..cf6f63bab3b5 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md @@ -1,4 +1,8 @@ -## NEXT +## 2.3.0 + +* Adds implementation for `cloudMapId` parameter to support cloud-based maps styling. + +## 2.2.0 * Updates minimum Flutter version to 3.0. diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/integration_test/google_maps_test.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/integration_test/google_maps_test.dart index eb00ccb673f4..a2f551370be9 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/integration_test/google_maps_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/integration_test/google_maps_test.dart @@ -16,6 +16,7 @@ const LatLng _kInitialMapCenter = LatLng(0, 0); const double _kInitialZoomLevel = 5; const CameraPosition _kInitialCameraPosition = CameraPosition(target: _kInitialMapCenter, zoom: _kInitialZoomLevel); +const String _kCloudMapId = '8e0a97af9386fef'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); @@ -1024,6 +1025,19 @@ void main() { expect(tileOverlayInfo1, isNull); }, ); + + testWidgets('testSetStyleMapId', (WidgetTester tester) async { + final Key key = GlobalKey(); + + await tester.pumpWidget(Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + cloudMapId: _kCloudMapId, + ), + )); + }); } class _DebugTileProvider implements TileProvider { diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/lib/example_google_map.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/lib/example_google_map.dart index 1c1261cb5b82..5357b30f183e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/lib/example_google_map.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/lib/example_google_map.dart @@ -247,6 +247,7 @@ class ExampleGoogleMap extends StatefulWidget { this.onCameraIdle, this.onTap, this.onLongPress, + this.cloudMapId, }) : super(key: key); /// Callback method for when the map is ready to be used. @@ -349,6 +350,12 @@ class ExampleGoogleMap extends StatefulWidget { /// Which gestures should be consumed by the map. final Set> gestureRecognizers; + /// Identifier that's associated with a specific cloud bases map style. + /// + /// See https://developers.google.com/maps/documentation/get-map-id + /// for more details. + final String? cloudMapId; + /// Creates a [State] for this [ExampleGoogleMap]. @override State createState() => _ExampleGoogleMapState(); @@ -534,5 +541,6 @@ MapConfiguration _configurationFromMapWidget(ExampleGoogleMap map) { indoorViewEnabled: map.indoorViewEnabled, trafficEnabled: map.trafficEnabled, buildingsEnabled: map.buildingsEnabled, + cloudMapId: map.cloudMapId, ); } diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/lib/main.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/lib/main.dart index de75162b09dd..942db4ddbcfe 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/lib/main.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/lib/main.dart @@ -8,6 +8,7 @@ import 'animate_camera.dart'; import 'lite_mode.dart'; import 'map_click.dart'; import 'map_coordinates.dart'; +import 'map_map_id.dart'; import 'map_ui.dart'; import 'marker_icons.dart'; import 'move_camera.dart'; @@ -37,6 +38,7 @@ final List _allPages = [ const SnapshotPage(), const LiteModePage(), const TileOverlayPage(), + const MapIdPage(), ]; /// MapsDemo is the Main Application. diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/lib/map_map_id.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/lib/map_map_id.dart new file mode 100644 index 000000000000..20843895d523 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/lib/map_map_id.dart @@ -0,0 +1,115 @@ +// 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. + +// ignore_for_file: public_member_api_docs + +import 'package:flutter/material.dart'; +import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; + +import 'example_google_map.dart'; +import 'page.dart'; + +class MapIdPage extends GoogleMapExampleAppPage { + const MapIdPage({Key? key}) + : super(const Icon(Icons.map), 'Cloud-based maps styling', key: key); + + @override + Widget build(BuildContext context) { + return const MapIdBody(); + } +} + +class MapIdBody extends StatefulWidget { + const MapIdBody({Key? key}) : super(key: key); + + @override + State createState() => MapIdBodyState(); +} + +const LatLng _kMapCenter = LatLng(52.4478, -3.5402); + +class MapIdBodyState extends State { + ExampleGoogleMapController? controller; + + Key _key = const Key('mapId#'); + String? _mapId; + final TextEditingController _mapIdController = TextEditingController(); + + void _setMapId() { + setState(() { + _mapId = _mapIdController.text; + + // Change key to initialize new map instance for new mapId. + _key = Key(_mapId ?? 'mapId#'); + }); + } + + @override + Widget build(BuildContext context) { + final ExampleGoogleMap googleMap = ExampleGoogleMap( + onMapCreated: _onMapCreated, + initialCameraPosition: const CameraPosition( + target: _kMapCenter, + zoom: 7.0, + ), + key: _key, + cloudMapId: _mapId, + ); + + final List columnChildren = [ + Padding( + padding: const EdgeInsets.all(10.0), + child: Center( + child: SizedBox( + width: 300.0, + height: 200.0, + child: googleMap, + ), + ), + ), + Padding( + padding: const EdgeInsets.all(10.0), + child: TextField( + controller: _mapIdController, + decoration: const InputDecoration( + hintText: 'Map Id', + ), + ), + ), + Padding( + padding: const EdgeInsets.all(10.0), + child: ElevatedButton( + onPressed: () => _setMapId(), + child: const Text( + 'Press to use specified map Id', + ), + ), + ), + const Padding( + padding: EdgeInsets.all(10.0), + child: + Text('On iOS, cloud based map styling works only if iOS platform ' + 'version 12 or above is targeted in project Podfile. ' + "Run command 'pod update GoogleMaps' to update plugin"), + ) + ]; + + return Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: columnChildren, + ); + } + + @override + void dispose() { + _mapIdController.dispose(); + super.dispose(); + } + + void _onMapCreated(ExampleGoogleMapController controllerParam) { + setState(() { + controller = controllerParam; + }); + } +} diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_ios/example/pubspec.yaml index ac27996fbc25..2f2df32e987d 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/pubspec.yaml @@ -32,3 +32,11 @@ flutter: uses-material-design: true assets: - assets/ + + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + google_maps_flutter_ios: + path: ../../../google_maps_flutter/google_maps_flutter_ios + google_maps_flutter_platform_interface: + path: ../../../google_maps_flutter/google_maps_flutter_platform_interface diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m index bd50c2d7a6de..31e1fd9d8402 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m @@ -78,7 +78,19 @@ - (instancetype)initWithFrame:(CGRect)frame registrar:(NSObject *)registrar { GMSCameraPosition *camera = [FLTGoogleMapJSONConversions cameraPostionFromDictionary:args[@"initialCameraPosition"]]; - GMSMapView *mapView = [GMSMapView mapWithFrame:frame camera:camera]; + GMSMapView *mapView; + +#if defined(__IPHONE_12_0) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_12_0 + if (args[@"options"][@"cloudMapId"]) { + GMSMapID *mapID = [GMSMapID mapIDWithIdentifier:args[@"options"][@"cloudMapId"]]; + mapView = [GMSMapView mapWithFrame:frame mapID:mapID camera:camera]; + } else { + mapView = [GMSMapView mapWithFrame:frame camera:camera]; + } +#else + mapView = [GMSMapView mapWithFrame:frame camera:camera]; +#endif + return [self initWithMapView:mapView viewIdentifier:viewId arguments:args registrar:registrar]; } diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_maps_flutter_ios.dart b/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_maps_flutter_ios.dart index a0b46f0a96d1..0c0bac86afb0 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_maps_flutter_ios.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_maps_flutter_ios.dart @@ -641,6 +641,7 @@ Map _jsonForMapConfiguration(MapConfiguration config) { if (config.trafficEnabled != null) 'trafficEnabled': config.trafficEnabled!, if (config.buildingsEnabled != null) 'buildingsEnabled': config.buildingsEnabled!, + if (config.cloudMapId != null) 'cloudMapId': config.cloudMapId!, }; } diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml index c4f8d23cb382..c262a388b784 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter_ios description: iOS implementation of the google_maps_flutter plugin. repository: https://github.com/flutter/plugins/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.1.13 +version: 2.3.0 environment: sdk: ">=2.14.0 <3.0.0" @@ -27,3 +27,9 @@ dev_dependencies: flutter_test: sdk: flutter plugin_platform_interface: ^2.0.0 + + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + google_maps_flutter_platform_interface: + path: ../../google_maps_flutter/google_maps_flutter_platform_interface diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md index b3d6c5540e7a..9823951f989c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 2.3.0 +* Adds a `cloudMapId` parameter to support cloud-based map styling. * Updates minimum Flutter version to 3.0. ## 2.2.5 diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/map_configuration.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/map_configuration.dart index 4b43caffe5b6..1f907c79baf2 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/map_configuration.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/map_configuration.dart @@ -33,6 +33,7 @@ class MapConfiguration { this.indoorViewEnabled, this.trafficEnabled, this.buildingsEnabled, + this.cloudMapId, }); /// True if the compass UI should be shown. @@ -90,6 +91,12 @@ class MapConfiguration { /// True if 3D building display should be enabled. final bool? buildingsEnabled; + /// Identifier that's associated with a specific cloud bases 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 /// that are different from [other]. MapConfiguration diffFrom(MapConfiguration other) { @@ -143,6 +150,7 @@ class MapConfiguration { trafficEnabled != other.trafficEnabled ? trafficEnabled : null, buildingsEnabled: buildingsEnabled != other.buildingsEnabled ? buildingsEnabled : null, + cloudMapId: cloudMapId != other.cloudMapId ? cloudMapId : null, ); } @@ -171,6 +179,7 @@ class MapConfiguration { indoorViewEnabled: diff.indoorViewEnabled ?? indoorViewEnabled, trafficEnabled: diff.trafficEnabled ?? trafficEnabled, buildingsEnabled: diff.buildingsEnabled ?? buildingsEnabled, + cloudMapId: diff.cloudMapId ?? cloudMapId, ); } @@ -193,7 +202,8 @@ class MapConfiguration { padding == null && indoorViewEnabled == null && trafficEnabled == null && - buildingsEnabled == null; + buildingsEnabled == null && + cloudMapId == null; @override bool operator ==(Object other) { @@ -221,7 +231,8 @@ class MapConfiguration { padding == other.padding && indoorViewEnabled == other.indoorViewEnabled && trafficEnabled == other.trafficEnabled && - buildingsEnabled == other.buildingsEnabled; + buildingsEnabled == other.buildingsEnabled && + cloudMapId == other.cloudMapId; } @override @@ -244,5 +255,6 @@ class MapConfiguration { indoorViewEnabled, trafficEnabled, buildingsEnabled, + cloudMapId, ); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml index 6dfff89f8c4b..da7168533d4d 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml @@ -4,7 +4,7 @@ repository: https://github.com/flutter/plugins/tree/main/packages/google_maps_fl 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.2.5 +version: 2.3.0 environment: sdk: '>=2.12.0 <3.0.0' diff --git a/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md index 42930348965f..c45e5f50d35e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 0.4.1 +* Adds implementation for `cloudMapId` parameter to support cloud-based maps styling. * Updates minimum Flutter version to 3.0. ## 0.4.0+5 diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart index 0226234ea97a..fb45d87f6882 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart @@ -19,6 +19,7 @@ import 'google_maps_controller_test.mocks.dart'; // This value is used when comparing long~num, like // LatLng values. const double _acceptableDelta = 0.0000000001; +const String _kCloudMapId = '8e0a97af9386fef'; @GenerateMocks([], customMocks: >[ MockSpec(onMissingStub: OnMissingStub.returnDefault), @@ -387,6 +388,7 @@ void main() { mapConfiguration: const MapConfiguration( mapType: MapType.satellite, zoomControlsEnabled: true, + cloudMapId: _kCloudMapId, )); controller.debugSetOverrides( createMap: (_, gmaps.MapOptions options) { @@ -399,6 +401,7 @@ void main() { expect(capturedOptions, isNotNull); expect(capturedOptions!.mapTypeId, gmaps.MapTypeId.SATELLITE); expect(capturedOptions!.zoomControl, true); + expect(capturedOptions!.mapId, _kCloudMapId); expect(capturedOptions!.gestureHandling, 'auto', reason: 'by default the map handles zoom/pan gestures internally'); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml index 43f67946464a..2d275cc825d1 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml @@ -26,3 +26,13 @@ dev_dependencies: integration_test: sdk: flutter mockito: ^5.3.2 + + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + google_maps_flutter: + path: ../../../google_maps_flutter/google_maps_flutter + google_maps_flutter_platform_interface: + path: ../../../google_maps_flutter/google_maps_flutter_platform_interface + google_maps_flutter_web: + path: ../../../google_maps_flutter/google_maps_flutter_web diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart index 25cba849475b..0e3474c60c70 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart @@ -122,6 +122,14 @@ gmaps.MapOptions _applyInitialPosition( return options; } +gmaps.MapOptions _applyMapId( + String? mapId, + gmaps.MapOptions options, +) { + options.mapId = mapId; + return options; +} + // The keys we'd expect to see in a serialized MapTypeStyle JSON object. final Set _mapStyleKeys = { 'elementType', diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart index a659fb218803..e41aabc147b9 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart @@ -160,6 +160,7 @@ class GoogleMapController { _lastMapConfiguration, _lastStyles); // Initial position can only to be set here! options = _applyInitialPosition(_initialCameraPosition, options); + options = _applyMapId(_lastMapConfiguration.cloudMapId, options); // Create the map... final gmaps.GMap map = _createMap(_div, options); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml index 072d584b133f..3c4a64dac693 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter_web description: Web platform implementation of google_maps_flutter repository: https://github.com/flutter/plugins/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.4.0+5 +version: 0.4.1 environment: sdk: ">=2.12.0 <3.0.0" @@ -33,3 +33,9 @@ dev_dependencies: # The example deliberately includes limited-use secrets. false_secrets: - /example/web/index.html + + +# FOR TESTING ONLY. DO NOT MERGE. +dependency_overrides: + google_maps_flutter_platform_interface: + path: ../../google_maps_flutter/google_maps_flutter_platform_interface From 7e09827e6e3f74a03df2e776bde2eab33213f638 Mon Sep 17 00:00:00 2001 From: Joonas Kerttula Date: Thu, 8 Dec 2022 11:41:21 +0200 Subject: [PATCH 2/6] [google_maps_flutter] examples - move renderer initialization --- .../google_maps_flutter/example/lib/main.dart | 30 +++++++++++++++++++ .../example/lib/map_map_id.dart | 27 ++--------------- .../example/lib/main.dart | 26 ++++++++++++++++ .../example/lib/map_map_id.dart | 29 ++---------------- 4 files changed, 62 insertions(+), 50 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/main.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/main.dart index 19a798ecc0ee..e8ca5dc28b3e 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/main.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/main.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:google_maps_flutter_android/google_maps_flutter_android.dart'; import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; @@ -77,6 +79,34 @@ void main() { GoogleMapsFlutterPlatform.instance; if (mapsImplementation is GoogleMapsFlutterAndroid) { mapsImplementation.useAndroidViewSurface = true; + initializeMapRenderer(); } runApp(const MaterialApp(home: MapsDemo())); } + +Completer? _initializedRendererCompleter; + +/// Initializes map renderer to with `latest` renderer type for Android platform. +/// The renderer must be requested before creating GoogleMap instances, +/// as the renderer can be initialized only once per application context. +Future initializeMapRenderer() async { + if (_initializedRendererCompleter != null) { + return _initializedRendererCompleter!.future; + } + + _initializedRendererCompleter = Completer(); + + WidgetsFlutterBinding.ensureInitialized(); + + final GoogleMapsFlutterPlatform mapsImplementation = + GoogleMapsFlutterPlatform.instance; + if (mapsImplementation is GoogleMapsFlutterAndroid) { + mapsImplementation.initializeWithRenderer(AndroidMapRenderer.latest).then( + (AndroidMapRenderer initializedRenderer) => + _initializedRendererCompleter!.complete(initializedRenderer)); + } else { + _initializedRendererCompleter!.complete(null); + } + + return _initializedRendererCompleter!.future; +} diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/map_map_id.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/map_map_id.dart index ea5db0927655..797f939ce279 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/map_map_id.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/map_map_id.dart @@ -4,13 +4,12 @@ // ignore_for_file: public_member_api_docs -import 'dart:async'; import 'dart:io'; import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:google_maps_flutter_android/google_maps_flutter_android.dart'; -import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; +import 'main.dart'; import 'page.dart'; class MapIdPage extends GoogleMapExampleAppPage { @@ -42,7 +41,7 @@ class MapIdBodyState extends State { @override void initState() { - _initializeMapRenderer() + initializeMapRenderer() .then((AndroidMapRenderer? initializedRenderer) => setState(() { _initializedRenderer = initializedRenderer; })); @@ -56,7 +55,7 @@ class MapIdBodyState extends State { case AndroidMapRenderer.legacy: return 'legacy'; default: - return 'initializing'; + return 'unknown'; } } @@ -142,23 +141,3 @@ class MapIdBodyState extends State { }); } } - -Completer? _initializedRendererCompleter; -Future _initializeMapRenderer() async { - if (_initializedRendererCompleter != null) { - return _initializedRendererCompleter!.future; - } - - _initializedRendererCompleter = Completer(); - final GoogleMapsFlutterPlatform mapsImplementation = - GoogleMapsFlutterPlatform.instance; - if (mapsImplementation is GoogleMapsFlutterAndroid) { - mapsImplementation.initializeWithRenderer(AndroidMapRenderer.latest).then( - (AndroidMapRenderer initializedRenderer) => - _initializedRendererCompleter!.complete(initializedRenderer)); - } else { - _initializedRendererCompleter!.complete(null); - } - - return _initializedRendererCompleter!.future; -} diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/main.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/main.dart index d502870bcb29..dd6a5bc58282 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/main.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/main.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:google_maps_flutter_android/google_maps_flutter_android.dart'; import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; @@ -76,5 +78,29 @@ void main() { final GoogleMapsFlutterPlatform platform = GoogleMapsFlutterPlatform.instance; // Default to Hybrid Composition for the example. (platform as GoogleMapsFlutterAndroid).useAndroidViewSurface = true; + initializeMapRenderer(); runApp(const MaterialApp(home: MapsDemo())); } + +Completer? _initializedRendererCompleter; + +/// Initializes map renderer to with `latest` renderer type. +/// The renderer must be requested before creating GoogleMap instances, +/// as the renderer can be initialized only once per application context. +Future initializeMapRenderer() async { + if (_initializedRendererCompleter != null) { + return _initializedRendererCompleter!.future; + } + + _initializedRendererCompleter = Completer(); + + WidgetsFlutterBinding.ensureInitialized(); + + final GoogleMapsFlutterPlatform platform = GoogleMapsFlutterPlatform.instance; + (platform as GoogleMapsFlutterAndroid) + .initializeWithRenderer(AndroidMapRenderer.latest) + .then((AndroidMapRenderer initializedRenderer) => + _initializedRendererCompleter!.complete(initializedRenderer)); + + return _initializedRendererCompleter!.future; +} diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_map_id.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_map_id.dart index d9ef73aff1fe..ede75459ca99 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_map_id.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_map_id.dart @@ -4,13 +4,12 @@ // ignore_for_file: public_member_api_docs -import 'dart:async'; - import 'package:flutter/material.dart'; import 'package:google_maps_flutter_android/google_maps_flutter_android.dart'; import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; import 'example_google_map.dart'; +import 'main.dart'; import 'page.dart'; class MapIdPage extends GoogleMapExampleAppPage { @@ -42,7 +41,7 @@ class MapIdBodyState extends State { @override void initState() { - _initializeMapRenderer() + initializeMapRenderer() .then((AndroidMapRenderer? initializedRenderer) => setState(() { _initializedRenderer = initializedRenderer; })); @@ -56,7 +55,7 @@ class MapIdBodyState extends State { case AndroidMapRenderer.legacy: return 'legacy'; default: - return 'initializing'; + return 'unknown'; } } @@ -134,25 +133,3 @@ class MapIdBodyState extends State { }); } } - -Completer? _initializedRendererCompleter; -Future _initializeMapRenderer() async { - // Map renderer can be requested only once. - // Returns existing copleter future for serial requests. - if (_initializedRendererCompleter != null) { - return _initializedRendererCompleter!.future; - } - - _initializedRendererCompleter = Completer(); - final GoogleMapsFlutterPlatform mapsImplementation = - GoogleMapsFlutterPlatform.instance; - if (mapsImplementation is GoogleMapsFlutterAndroid) { - mapsImplementation.initializeWithRenderer(AndroidMapRenderer.latest).then( - (AndroidMapRenderer initializedRenderer) => - _initializedRendererCompleter!.complete(initializedRenderer)); - } else { - _initializedRendererCompleter!.complete(null); - } - - return _initializedRendererCompleter!.future; -} From 728053bc3033b0a316a7361518e641a748696d2a Mon Sep 17 00:00:00 2001 From: Joonas Kerttula Date: Wed, 1 Feb 2023 15:17:01 +0200 Subject: [PATCH 3/6] [google_maps_flutter] Fix versioning --- .../google_maps_flutter/google_maps_flutter/CHANGELOG.md | 5 +---- .../google_maps_flutter/example/pubspec.yaml | 1 - .../google_maps_flutter/google_maps_flutter/pubspec.yaml | 2 +- .../google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md | 5 +---- .../google_maps_flutter/google_maps_flutter_ios/pubspec.yaml | 2 +- 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md index bb5aa5985f4e..896b21bbbdc3 100644 --- a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md @@ -1,9 +1,6 @@ -## 2.4.0 - -* Adds implementation for `cloudMapId` parameter to support cloud-based maps styling. - ## 2.3.0 +* Adds implementation for `cloudMapId` parameter to support cloud-based maps styling. * Updates minimum Flutter version to 3.0. ## 2.2.3 diff --git a/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml index 08f598f4e640..2db7e6035f9d 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml @@ -19,7 +19,6 @@ dependencies: # the parent directory to use the current plugin's version. path: ../ google_maps_flutter_android: ^2.1.10 - google_maps_flutter_ios: ^2.1.10 google_maps_flutter_platform_interface: ^2.2.1 dev_dependencies: diff --git a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml index 52f74cbdfe53..f0d3c064e96b 100644 --- a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml @@ -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/plugins/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.4.0 +version: 2.3.0 environment: sdk: ">=2.14.0 <3.0.0" diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md index cf6f63bab3b5..96dd6312e3c7 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md @@ -1,9 +1,6 @@ -## 2.3.0 - -* Adds implementation for `cloudMapId` parameter to support cloud-based maps styling. - ## 2.2.0 +* Adds implementation for `cloudMapId` parameter to support cloud-based maps styling. * Updates minimum Flutter version to 3.0. ## 2.1.13 diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml index c262a388b784..ffd61462d56e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter_ios description: iOS implementation of the google_maps_flutter plugin. repository: https://github.com/flutter/plugins/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.3.0 +version: 2.2.0 environment: sdk: ">=2.14.0 <3.0.0" From 685b8f1f828ca4b9ebe684adecc6b1e8a94d29fd Mon Sep 17 00:00:00 2001 From: Joonas Kerttula Date: Thu, 2 Feb 2023 12:29:53 +0200 Subject: [PATCH 4/6] [google_maps_flutter] updated tests and documentation --- packages/google_maps_flutter/google_maps_flutter/README.md | 4 ++++ .../example/integration_test/google_maps_test.dart | 2 +- .../google_maps_flutter/lib/src/google_map.dart | 2 +- .../example/integration_test/google_maps_tests.dart | 2 +- .../example/lib/example_google_map.dart | 2 +- .../example/integration_test/google_maps_test.dart | 2 +- .../example/lib/example_google_map.dart | 2 +- .../lib/src/types/map_configuration.dart | 2 +- .../example/integration_test/google_maps_controller_test.dart | 2 +- 9 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/README.md b/packages/google_maps_flutter/google_maps_flutter/README.md index 687672353a7e..c7fa73fc9480 100644 --- a/packages/google_maps_flutter/google_maps_flutter/README.md +++ b/packages/google_maps_flutter/google_maps_flutter/README.md @@ -58,6 +58,10 @@ The Android implementation supports multiple [platform view display modes](https://flutter.dev/docs/development/platform-integration/platform-views). For details, see [the Android README](https://pub.dev/packages/google_maps_flutter_android#display-mode). +#### Cloud-based map styling +Cloud-based map styling works on Android platform only if `AndroidMapRenderer.latest` has been initialized. +For details, see [the Android README](https://pub.dev/packages/google_maps_flutter_android#map-renderer). + ### iOS To set up, specify your API key in the application delegate `ios/Runner/AppDelegate.m`: diff --git a/packages/google_maps_flutter/google_maps_flutter/example/integration_test/google_maps_test.dart b/packages/google_maps_flutter/google_maps_flutter/example/integration_test/google_maps_test.dart index b5ab166f4a61..fe3b0477cbd4 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/integration_test/google_maps_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/integration_test/google_maps_test.dart @@ -17,7 +17,7 @@ const LatLng _kInitialMapCenter = LatLng(0, 0); const double _kInitialZoomLevel = 5; const CameraPosition _kInitialCameraPosition = CameraPosition(target: _kInitialMapCenter, zoom: _kInitialZoomLevel); -const String _kCloudMapId = '8e0a97af9386fef'; +const String _kCloudMapId = '000000000000000'; // Dummy map ID. void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); diff --git a/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart b/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart index c03404b21eeb..0110736ac407 100644 --- a/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart +++ b/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart @@ -284,7 +284,7 @@ class GoogleMap extends StatefulWidget { /// were not claimed by any other gesture recognizer. final Set> gestureRecognizers; - /// Identifier that's associated with a specific cloud bases map style. + /// Identifier that's associated with a specific cloud-based map style. /// /// See https://developers.google.com/maps/documentation/get-map-id /// for more details. diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_tests.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_tests.dart index 584b5eaa069c..543762e3fac7 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_tests.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_tests.dart @@ -17,7 +17,7 @@ const LatLng _kInitialMapCenter = LatLng(0, 0); const double _kInitialZoomLevel = 5; const CameraPosition _kInitialCameraPosition = CameraPosition(target: _kInitialMapCenter, zoom: _kInitialZoomLevel); -const String _kCloudMapId = '8e0a97af9386fef'; +const String _kCloudMapId = '000000000000000'; // Dummy map ID. void googleMapsTests() { GoogleMapsFlutterPlatform.instance.enableDebugInspection(); diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/example_google_map.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/example_google_map.dart index 5357b30f183e..f58486bf5928 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/example_google_map.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/example_google_map.dart @@ -350,7 +350,7 @@ class ExampleGoogleMap extends StatefulWidget { /// Which gestures should be consumed by the map. final Set> gestureRecognizers; - /// Identifier that's associated with a specific cloud bases map style. + /// Identifier that's associated with a specific cloud-based map style. /// /// See https://developers.google.com/maps/documentation/get-map-id /// for more details. diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/integration_test/google_maps_test.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/integration_test/google_maps_test.dart index a2f551370be9..f31ca544fb28 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/integration_test/google_maps_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/integration_test/google_maps_test.dart @@ -16,7 +16,7 @@ const LatLng _kInitialMapCenter = LatLng(0, 0); const double _kInitialZoomLevel = 5; const CameraPosition _kInitialCameraPosition = CameraPosition(target: _kInitialMapCenter, zoom: _kInitialZoomLevel); -const String _kCloudMapId = '8e0a97af9386fef'; +const String _kCloudMapId = '000000000000000'; // Dummy map ID. void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/lib/example_google_map.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/lib/example_google_map.dart index 5357b30f183e..f58486bf5928 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/lib/example_google_map.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/lib/example_google_map.dart @@ -350,7 +350,7 @@ class ExampleGoogleMap extends StatefulWidget { /// Which gestures should be consumed by the map. final Set> gestureRecognizers; - /// Identifier that's associated with a specific cloud bases map style. + /// Identifier that's associated with a specific cloud-based map style. /// /// See https://developers.google.com/maps/documentation/get-map-id /// for more details. diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/map_configuration.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/map_configuration.dart index 1f907c79baf2..5580e9eea98b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/map_configuration.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/map_configuration.dart @@ -91,7 +91,7 @@ class MapConfiguration { /// True if 3D building display should be enabled. final bool? buildingsEnabled; - /// Identifier that's associated with a specific cloud bases map style. + /// Identifier that's associated with a specific cloud-based map style. /// /// See https://developers.google.com/maps/documentation/get-map-id /// for more details. diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart index fb45d87f6882..866c7c2df35b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart @@ -19,7 +19,7 @@ import 'google_maps_controller_test.mocks.dart'; // This value is used when comparing long~num, like // LatLng values. const double _acceptableDelta = 0.0000000001; -const String _kCloudMapId = '8e0a97af9386fef'; +const String _kCloudMapId = '000000000000000'; // Dummy map ID. @GenerateMocks([], customMocks: >[ MockSpec(onMissingStub: OnMissingStub.returnDefault), From e8efba620bec9b1bf01102201bfe7b8715ad2433 Mon Sep 17 00:00:00 2001 From: Joonas Kerttula Date: Thu, 2 Feb 2023 12:42:05 +0200 Subject: [PATCH 5/6] [google_maps_flutter] Fix readme --- packages/google_maps_flutter/google_maps_flutter/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/README.md b/packages/google_maps_flutter/google_maps_flutter/README.md index c7fa73fc9480..7866a8e4b71a 100644 --- a/packages/google_maps_flutter/google_maps_flutter/README.md +++ b/packages/google_maps_flutter/google_maps_flutter/README.md @@ -59,7 +59,7 @@ The Android implementation supports multiple For details, see [the Android README](https://pub.dev/packages/google_maps_flutter_android#display-mode). #### Cloud-based map styling -Cloud-based map styling works on Android platform only if `AndroidMapRenderer.latest` has been initialized. +Cloud-based map styling works on Android platform only if `AndroidMapRenderer.latest` map renderer has been initialized. For details, see [the Android README](https://pub.dev/packages/google_maps_flutter_android#map-renderer). ### iOS From 2673fb3b95752ab9587ad8526ee4aaa68731386c Mon Sep 17 00:00:00 2001 From: Joonas Kerttula Date: Thu, 2 Feb 2023 12:57:15 +0200 Subject: [PATCH 6/6] Fix violations --- .../google_maps_flutter/example/lib/map_map_id.dart | 6 ++++-- .../google_maps_flutter_android/example/lib/map_map_id.dart | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/map_map_id.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/map_map_id.dart index 797f939ce279..6fcd3cd197c2 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/map_map_id.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/map_map_id.dart @@ -54,9 +54,11 @@ class MapIdBodyState extends State { return 'latest'; case AndroidMapRenderer.legacy: return 'legacy'; - default: - return 'unknown'; + case AndroidMapRenderer.platformDefault: + case null: + break; } + return 'unknown'; } void _setMapId() { diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_map_id.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_map_id.dart index ede75459ca99..da094eb7df7b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_map_id.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_map_id.dart @@ -54,9 +54,11 @@ class MapIdBodyState extends State { return 'latest'; case AndroidMapRenderer.legacy: return 'legacy'; - default: - return 'unknown'; + case AndroidMapRenderer.platformDefault: + case null: + break; } + return 'unknown'; } void _setMapId() {