Skip to content

google_maps_flutter setMapStyle before GoogleMap widget is rendered #66207

@kareldebedts

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.

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