flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
162.97k stars 26.8k forks source link

[google_maps] warning on the web when adding a map id #149060

Open cedvdb opened 1 month ago

cedvdb commented 1 month ago

Steps to reproduce

Warning:

Google Maps JavaScript API: A Map's styles property cannot be set when a mapId is present. When a mapId is present, Map styles are controlled via the cloud console. Please see documentation at

Expected results

no warning

Actual results

Google Maps JavaScript API: A Map's styles property cannot be set when a mapId is present. When a mapId is present, Map styles are controlled via the cloud console. Please see documentation at

Code sample

Code sample ```dart GoogleMap( onMapCreated: onMapCreated, initialCameraPosition: _kInitialPosition, onTap: (LatLng pos) { setState(() { _lastTap = pos; }); }, onLongPress: (LatLng pos) { setState(() { _lastLongPress = pos; }); }, cloudMapId: 'YOUR ID HERE', ) ```

Screenshots or Video

Screenshots / Video demonstration [Upload media here]

Logs

Logs ```console [Paste your logs here] ```

Flutter Doctor output

example (main): flutter doctor Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.22.1, on Microsoft Windows [Version 10.0.22631.3593], locale en-BE) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [√] Chrome - develop for the web [√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.32) [√] Android Studio (version 2023.1) [√] VS Code (version 1.89.1) [√] Connected device (3 available) [√] Network resources

• No issues found!

darshankawar commented 1 month ago

Thanks for the report @cedvdb Have you checked this information from package's readMe ? https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter#cloud-based-map-styling

cedvdb commented 1 month ago

@darshankawar the part of the readme you linked does not seem to be relevant to this issue.

I believe the issue is that the plugin, in the source code, still provides style information to google map, last time I checked the source code. It should not pass style information if a cloud id was provided

It's been a long time I checked the source code of flutter_google_map but last time this involved some sort of map that was edited with all values passed to google map. The style / styling key should not be added when there is a cloudMapId provided by the user of the plugin

darshankawar commented 4 weeks ago

Thanks for the update. It looks like it is something coming from Google's maps directly based on https://issuetracker.google.com/issues/161501609?pli=1 that you can check

cedvdb commented 4 weeks ago

Edit: Nvm, I made a fix https://github.com/flutter/packages/pull/6821

@darshankawar No. I know you have a lot of issues to track so I'll be more clear.

You cannot use mapIds (cloud map id) and styles at the same time. When you do, you'll get the warning.

Google Maps JavaScript API: A Map's styles property cannot be set when a mapId is present. When a mapId is present, Map styles are controlled via the cloud console. Please see documentation at ...

Internally the flutter packages passes both to gmap. It should not give the styles in configuration at all (even if empty) when it receives a cloud map id because cloud map id are already used for styling.

From a quick look the issue might be on this line which should not add anything if a cloudMapId is set (i'm not sure though).

Changing it into something like the following might solve the issue.

if (! cloudMapId) {
   options.styles = styles;
}
darshankawar commented 4 weeks ago

Thanks for the feedback and potential fix. I was able to see the warning while trying to run the plugin example on web platform.

stable, master flutter doctor -v ``` [!] Flutter (Channel stable, 3.22.0, on macOS 12.2.1 21D62 darwin-x64, locale en-GB) • Flutter version 3.22.0 on channel stable at /Users/dhs/documents/fluttersdk/flutter ! Warning: `flutter` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. ! Warning: `dart` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision 5dcb86f68f (5 days ago), 2024-05-09 07:39:20 -0500 • Engine revision f6344b75dc • Dart version 3.4.0 • DevTools version 2.34.3 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [!] Xcode - develop for iOS and macOS (Xcode 12.3) • Xcode at /Applications/Xcode.app/Contents/Developer ! Flutter recommends a minimum Xcode version of 13. Download the latest version or update via the Mac App Store. • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] VS Code (version 1.62.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.21.0 [✓] Connected device (5 available) • SM G975F (mobile) • RZ8M802WY0X • android-arm64 • Android 11 (API 30) • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios • iOS 14.4.1 18D61 • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator) • macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.4 19E2269 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.80 [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 1 category. [!] Flutter (Channel master, 3.23.0-8.0.pre.8, on macOS 12.2.1 21D62 darwin-x64, locale en-GB) • Flutter version 3.23.0-8.0.pre.8 on channel master at /Users/dhs/documents/fluttersdk/flutter ! Warning: `flutter` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. ! Warning: `dart` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision 8fd8e66de4 (4 hours ago), 2024-05-26 21:49:30 -0400 • Engine revision 469193ef0e • Dart version 3.5.0 (build 3.5.0-191.0.dev) • DevTools version 2.36.0-dev.10 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /Users/dhs/Library/Android/sdk ✗ cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details. [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 13C100 • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] IntelliJ IDEA Ultimate Edition (version 2021.3.2) • IntelliJ at /Applications/IntelliJ IDEA.app • Flutter plugin version 65.1.4 • Dart plugin version 213.7228 [✓] VS Code (version 1.62.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.29.0 [✓] Connected device (3 available) • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios • iOS 15.3.1 19D52 • macOS (desktop) • macos • darwin-x64 • macOS 12.2.1 21D62 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.119 [✓] Network resources • All expected network resources are available. ! Doctor found issues in 1 category. [!] Xcode - develop for iOS and macOS (Xcode 12.3) • Xcode at /Applications/Xcode.app/Contents/Developer ! Flutter recommends a minimum Xcode version of 13. Download the latest version or update via the Mac App Store. • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] VS Code (version 1.62.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.21.0 [✓] Connected device (5 available) • SM G975F (mobile) • RZ8M802WY0X • android-arm64 • Android 11 (API 30) • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios • iOS 14.4.1 18D61 • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator) • macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.4 19E2269 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.80 [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 1 category. ```
stuartmorgan commented 3 weeks ago

@ditman It sounds like we are unconditionally using map style internally in the web implementation somewhere?

cedvdb commented 3 weeks ago

@stuartmorgan I believe there https://github.com/flutter/packages/pull/6821/files#diff-ad093591ababe86bff6ff2af9ce718a9b0ef32f011611922b7d245420c71cb27L87 , at least that seems to solve the issue.