Skip to content

google_maps_flutter setMapStyle before GoogleMap widget is rendered #66207

Description

@kareldebedts

Internal: b/249358651

Use case

It's currently possible to set a custom map style once the GoogleMap widget is rendered.

     GoogleMap(
                    onCameraMove: (CameraPosition cameraPosition) {
                      loadNewPubs(cameraPosition);
                    },
                    onMapCreated: _onMapCreated,
                    initialCameraPosition: CameraPosition(
                      target: LatLng(lat, lng),
                      zoom: 15,
                    ),
                    myLocationButtonEnabled: false,
                    myLocationEnabled: true,
                    mapToolbarEnabled: false,
                    zoomControlsEnabled: false,
                    markers: Set<Marker>.of(markers.values),
                  ),
  void _onMapCreated(GoogleMapController controller) {
    setState(() {
      _mapController = controller;
      _mapController.setMapStyle(_mapStyle).whenComplete(() {
      });
    });
  }

This results in a "flash" which is especially disturbing when using a dark map style.

Demonstrated in this video on an iPhone 11 Pro simulator.

The behavior:

  1. the widget isn't loaded: a pure white screen is rendered for a few 100 milliseconds.
  2. the default map style is rendered white yellow (beige) color, this is more visible.
  3. the custom map style is rendered

ezgif-7-1a215ae5cc85

Proposal

To avoid step 1: a possibility to set a custom background color (now it's the color white).
To avoid step 2: a possibility to set the map style before the googleMap widget is rendered and not on onMapCreated.

Activity

  1. added
    P2Important issues not at the top of the work list
    on May 23, 2021
  2. cedvdb commented on Jan 16, 2022

    @cedvdb
    Contributor

    It's possible to do with the js api, not sure about the android one.

    In the source of google_maps_flutter, the parameters passed to google map widget are put into a map and given to the underlying system api. If the underlying platform supports settings styles directly in map options it's an easy fix.

    Idk if all underlying platforms support it though

  3. BramDriesen commented on Jan 21, 2022

    @BramDriesen

    This is also happening when no map style is being used but if the GoogleMap is on a page which is being pushed by a Navigator.push in combination with a MaterialPageRoute

  4. cedvdb commented on Apr 5, 2022

    @cedvdb
    Contributor

    @pedromassango you added p4 to this issue but this one #67631 is p5

    The p5 one would fix this issue as well, and it is not clear whether that other issue would be a bigger change, it might even be less, although it would be breaking. It also comes with the benefit of fixing a few other issue. So imo that prioritization should be reconsidered.

  5. pedromassango commented on Jun 21, 2022

    @pedromassango
    Member

    @pedromassango you added p4 to this issue but this one #67631 is p5

    This is a bug, that one is a feature proposal

  6. added
    P1High-priority issues at the top of the work list
    and removed
    P2Important issues not at the top of the work list
    on Oct 3, 2022
  7. xster commented on Oct 3, 2022

    @xster
    Member

    Making a P3 to match Google bug b/249358651

  8. khyati82 commented on Oct 24, 2022

    @khyati82

    @stuartmorgan - Any update on this issue? Requesting response on behalf of 1P customer

  9. 25 remaining items

  10. github-actions commented on Mar 13, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  11. locked as resolved and limited conversation to collaborators on Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

P1High-priority issues at the top of the work listc: proposalA detailed proposal for a change to Fluttercustomer: googleVarious Google teamscustomer: huggsy (g3)p: mapsGoogle Maps pluginpackageflutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions