-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[google_maps_flutter] Cloud-based map styling support #6553
[google_maps_flutter] Cloud-based map styling support #6553
Conversation
Apparently updating the Google Maps iOS SDK to support GMMapID changes the required iOS target platform from version 9 to 12, which means this is a breaking change. I'll turn this PR into a draft for now, to find out how to proceed with this. |
I can see two options:
@jmagman Which way do you want to go with this? |
Upping the iOS min version is such a poor experience for the developer using the plugin since we have no helpful Flutter tooling, I think it just fails to compile, or maybe the |
I filed flutter/flutter#113762 |
When using runtime checks eg. Instead, using compile time #if functionality fixed linting issues, and seems like mapId can now be used when iOS platform 12+ is targeted. Should I upgrade the iOS platform version for example projects, as those are used for integration tests. If platform target version is not 12+, cloud mapId tests are run and passed, but the code block inside the #if -block does not get ever tested. Also if plugin is marked to be able to be run with iOS platform version 9, can the examples still target version 12, as this mean example projects cannot be run by users with iOS platform version 9 anymore? Haven't tested the plugin with iOS platform version <11 as current flutter version forces project to use version 11. For android, the cloud map id support is available only with LATEST renderer, which is not yet the default renderer for the Google Maps Android plugin. This PR adds also feature to target this latest renderer (and also legacy renderer if ever needed). This is now bundled with the plugin; another option would have been to point users to this documentation showing how to prefer latest renderer, but I see this would have been more complicated option for developers. |
What exactly was the error? If we can't use
Adding this is fine; I was actually planning on doing this anyway after recent discussions with the Google Maps team. Could you split that out into a separate PR that we can land first though, to simplify reviews? |
With simplified example:
Running this command (runned in github actions at Output:
So how to bypass the
Is there already issue for this? |
🤦🏻 Sorry, right; this is why I had suggested dynamic lookup initially, then I forgot over the weekend. If the only downside to |
Not yet, no. |
Separate PR for prefer map renderer for Android: #6619 |
Marking as draft until #6619 is landed and this PR updated to work against it. |
c47bb4a
to
8086f9d
Compare
PR is now updated and implements map renderer selection for android using existing api. |
@@ -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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what we should do with the testing map Id, since it is associated with the cloud account. We might need to inject this from ci?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with the details of our current testing setup for maps; do we have an account already for this? Or does this mean we need to set up and manage a new testing account, and associate our example app with that account? Is this directly connected to the API key, or orthogonal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do have a testing account, whose key is encrypted in https://github.com/flutter/plugins/blob/main/.cirrus.yml#L262
On iOS it is used as
plugins/packages/google_maps_flutter/google_maps_flutter_ios/example/ios/Runner/AppDelegate.m
Line 15 in edc6c0e
NSString *mapsApiKey = [[NSProcessInfo processInfo] environment][@"MAPS_API_KEY"]; |
I believe we will need to do something similar here. I think we should add the environment variable in a separate PR, update this PT after the environment variable is available on main.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_kCloudMapId value does not need to be valid mapId at google maps platform. Google Maps Native SDK's silently fall back to normal map if mapId is not available. This test is meant to test the API and not the SDK behaviour itself. I'll comment this variable, and test if I can change the hash to something that is clearly random id like "0000000000000000", and test that it still passes the tests on each platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks great, just a couple of minor questions. We just need to figure out the testing approach here.
Worst case we could probably just not integration test this, and rely on unit tests on both sides (Dart and native) to ensure that we're plumbing the ID through. That's less robust, but there's also not a lot of code of our own here so it's less critical.
...gle_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/map_configuration.dart
Outdated
Show resolved
Hide resolved
@@ -75,6 +79,34 @@ void main() { | |||
GoogleMapsFlutterPlatform.instance; | |||
if (mapsImplementation is GoogleMapsFlutterAndroid) { | |||
mapsImplementation.useAndroidViewSurface = true; | |||
initializeMapRenderer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The README should be updated to explain the requirement here, and this should have a comment referring to that to explain why it's here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Map renderers are already explained under google_maps_flutter_android package README.
I can update the app-facing plugin README and add information that cloud-based mapid works only on Android if latest renderer is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml
Outdated
Show resolved
Hide resolved
fa48a28
to
7e09827
Compare
We've just completed the migration of the plugin code to the flutter/packages repository, as described in https://flutter.dev/go/flutter-plugins-repo-migration, and this repository is now being archived. Unfortunately that means that all in-progress PRs here must be moved to flutter/packages. Please see our instructions for an explanation of how to move your PR, and if you have any issues moving your PR please don't hesitate to reach out in the #hackers-ecosystem channel in Discord. Our apologies that your PR was caught in this one-time transition. We're aware that it's disruptive in the short term, and appreciate your help in getting us to a better long-term state! |
Adds support for cloud-based map styling.
On Android, cloud-based maps styling works only with the new (opt-in) renderer, and feature to prefer latest renderer via AndroidManifest meta-data field is added as well.
New renderer will be rolled as default renderer in future releases of the Google Maps Android SDK. After that this feature can be still used to prefer legacy renderer, or can be obsoleted/removed from the package.
When using a cloud-based map Id, it can only be set during map initialization. Changing the map Id for an existing map instance is not supported. If the developer wants to change the map Id, this is easy to implement by changing the key of the widget, in which case the widget is re-initialized with a new map Id.
This is first step of the federated plugin multi-package PR process
Resolves flutter/flutter#67631
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.