I'm trying to use custom style with Cloud Map ID for google maps flutter. As always, I got the default style for maps even if I already define the cloud map id in google maps widget.
When I take a look at the console
D/MapsInitializer(32388): preferredRenderer: LATEST
D/zzcc (32388): preferredRenderer: LATEST
I/zzcc (32388): Making Creator dynamically
2
W/ziparchive(32388): Unable to open '/data/user_de/0/com.google.android.gms/app_chimera/m/00000002/DynamiteLoader.dm': No such file or directory
I/DynamiteModule(32388): Considering local module com.google.android.gms.maps_core_dynamite:0 and remote module com.google.android.gms.maps_core_dynamite:203115000
I/DynamiteModule(32388): Selected remote version of com.google.android.gms.maps_core_dynamite, version >= 203115000
V/DynamiteModule(32388): Dynamite loader version >= 2, using loadModule2NoCrashUtils
2
W/ziparchive(32388): Unable to open '/data/user_de/0/com.google.android.gms/app_chimera/m/00000006/MapsDynamite.dm': No such file or directory
I/Google Maps Android API(32388): Google Play services client version: 18020000
I/Google Maps Android API(32388): Google Play services package version: 231818044
I/Google Maps Android API(32388): Google Play services maps renderer version(legacy): 203115000
D/MapsInitializer(32388): loadedRenderer: LEGACY
W/Google Maps Android API(32388): MapId is not supported with the legacy renderer.
I/PlatformViewsController(32388): Hosting view in a virtual display for platform view: 0
E/FrameEvents(32388): updateAcquireFence: Did not find frame.
E/BufferQueueProducer(32388): [SurfaceTexture-0-32388-0](id:7e8400000002,api:1,p:32388,c:32388) connect: already connected (cur=1 req=1)
I/GoogleMapController(32388): No TextureView found. Likely using the LEGACY renderer.
E/OpenGLRenderer(32388): Unable to match the desired swap behavior.
I wonder why I always get the Legacy Renderer so the config for Cloud Map ID is not used. I already initialize the map Renderer so that the preferredRenderer is Latest.
final GoogleMapsFlutterPlatform mapsImplementation =
GoogleMapsFlutterPlatform.instance;
if (mapsImplementation is GoogleMapsFlutterAndroid) {
WidgetsFlutterBinding.ensureInitialized();
mapRenderer = await mapsImplementation
.initializeWithRenderer(AndroidMapRenderer.latest);
}
What am I doing wrong?
The error message indicates that the Google Maps Android API is using the legacy renderer and that the MapId is not supported with the legacy renderer. To use the Cloud Map ID for Google Maps in a Flutter app and ensure it works with the latest renderer, you need to make sure you have the necessary dependencies and configurations.
Here are steps you can follow:
Dependencies:
Ensure that you have the latest version of the google_maps_flutter
package in your pubspec.yaml
file. You can check for the latest version on pub.dev.
dependencies:
google_maps_flutter: ^latest_version
Run flutter pub get
to fetch the latest package.
Update Google Play Services:
Make sure that your Android project is using the latest version of Google Play services. You can check and update the version in the android/app/build.gradle
file.
implementation com.google.android.gms:play-services-maps:17.0.1
Sync your project after making changes.
Specify Cloud Map ID:
In your Google Maps widget, ensure that you are specifying the Cloud Map ID correctly. You can do this in the GoogleMap
widget:
GoogleMap(
mapType: MapType.normal,
initialCameraPosition: CameraPosition(
target: LatLng(yourInitialLatitude, yourInitialLongitude),
zoom: yourInitialZoom,
),
myLocationEnabled: true,
mapId: "your_cloud_map_id",
onMapCreated: (GoogleMapController controller) {
// Your map initialization code
},
)
Replace "your_cloud_map_id"
with your actual Cloud Map ID.
Check Renderer: Ensure that you are not explicitly setting the renderer to the legacy version. The renderer is automatically determined by the API.
Remove any code that explicitly sets the renderer or use of deprecated methods.
dartGoogleMapController(controllerId: 1, options: GoogleMapOptions(
// Remove any explicit renderer settings
))
Check API Key: Make sure your API key used in the Google Maps widget has the necessary permissions for the Google Maps services you are using.
After making these changes, rebuild your Flutter app and check if the Cloud Map ID is now being used with the latest renderer. If the issue persists, you may want to check the Google Maps Platform documentation for any additional updates or changes related to Cloud Map IDs.