-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[google_maps_flutter] cloud-based map styling implementation #4638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
auto-submit
merged 9 commits into
flutter:main
from
CodemateLtd:cbms_platform_implementations
Aug 24, 2023
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
64c40be
[google_maps_flutter] cloud-based map styling
jokerttu 7294950
[google_maps_flutter] Add tests for cloudMapId passing to platform_vi…
jokerttu 197b5ae
Merge branch 'main' into cbms_platform_implementations
jokerttu 17f3d9d
[google_maps_flutter_ios] add missing Directionality widget to ios un…
jokerttu 03db49a
Merge branch 'main' into cbms_platform_implementations
jokerttu 6056176
Merge branch 'amuramoto:main' into cbms_platform_implementations
jokerttu e498014
Merge branch 'main' into cbms_platform_implementations
jokerttu f5d1b89
Merge remote-tracking branch 'origin/main' into cbms_platform_impleme…
jokerttu 834f3bc
Merge branch 'main' into cbms_platform_implementations
jokerttu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_map_id.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| // 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_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 { | ||
| 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({super.key}); | ||
|
|
||
| @override | ||
| State<StatefulWidget> createState() => MapIdBodyState(); | ||
| } | ||
|
|
||
| const LatLng _kMapCenter = LatLng(52.4478, -3.5402); | ||
|
|
||
| class MapIdBodyState extends State<MapIdBody> { | ||
| ExampleGoogleMapController? controller; | ||
|
|
||
| Key _key = const Key('mapId#'); | ||
| String? _mapId; | ||
| final TextEditingController _mapIdController = TextEditingController(); | ||
| AndroidMapRenderer? _initializedRenderer; | ||
|
|
||
| @override | ||
| void initState() { | ||
| initializeMapRenderer() | ||
| .then<void>((AndroidMapRenderer? initializedRenderer) => setState(() { | ||
| _initializedRenderer = initializedRenderer; | ||
| })); | ||
| super.initState(); | ||
| } | ||
|
|
||
| String _getInitializedsRendererType() { | ||
| switch (_initializedRenderer) { | ||
| case AndroidMapRenderer.latest: | ||
| return 'latest'; | ||
| case AndroidMapRenderer.legacy: | ||
| return 'legacy'; | ||
| case AndroidMapRenderer.platformDefault: | ||
| case null: | ||
| break; | ||
| } | ||
| return 'unknown'; | ||
| } | ||
|
|
||
| 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<Widget> columnChildren = <Widget>[ | ||
| 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 (_initializedRenderer != AndroidMapRenderer.latest) | ||
| 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; | ||
| }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.