-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[google_maps_flutter] Cloud-based map styling support #3682
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
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d21a17e
[google_maps_flutter] support cloud-based maps styling
jokerttu 761d06c
[google_maps_flutter] update version to 2.5.0
jokerttu fb7a3ea
[google_maps_flutter] fix web tests for cloudMapId
jokerttu 991d197
Merge branch 'main' into cbms
jokerttu c5edd38
Merge branch 'main' into cbms
jokerttu 49aa3a1
Merge branch 'main' into cbms
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
4 changes: 4 additions & 0 deletions
4
packages/google_maps_flutter/google_maps_flutter/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
4 changes: 2 additions & 2 deletions
4
packages/google_maps_flutter/google_maps_flutter/example/ios/Podfile
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
140 changes: 140 additions & 0 deletions
140
packages/google_maps_flutter/google_maps_flutter/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,140 @@ | ||
// 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:io'; | ||
|
||
import 'package:flutter/foundation.dart'; | ||
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 '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> { | ||
GoogleMapController? 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 GoogleMap googleMap = GoogleMap( | ||
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 (!kIsWeb && | ||
Platform.isAndroid && | ||
_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()}".'), | ||
amuramoto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
), | ||
]; | ||
|
||
return Column( | ||
crossAxisAlignment: CrossAxisAlignment.stretch, | ||
children: columnChildren, | ||
); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
_mapIdController.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
void _onMapCreated(GoogleMapController 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
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.