Skip to content

[google_maps_flutter] ClipRRect of map does not work on iOS #30117

@jamespfinn

Description

@jamespfinn

The behavior of the GoogleMap() widget differs on Android vs iOS. When wrapped in a ClipRRect() to add a borderRadius, the maps displays as expected on Android but not iOS.

Included below is an example project and screenshot displaying the issue:
image

class _MyHomePageState extends State<MyHomePage> {
  final Completer<GoogleMapController> _controller = Completer();
  final CameraPosition _googleHQ = CameraPosition(
    bearing: 0,
    target: LatLng(37.422, -122.084),
    tilt: 45,
    zoom: 16,
  );

  @override
  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Container(
          height: 300,
          width: 300,
          child: ClipRRect(
            borderRadius: BorderRadius.all(Radius.circular(50.0)),
            child: GoogleMap(
              mapType: MapType.hybrid,
              initialCameraPosition: _googleHQ,
              onMapCreated: (GoogleMapController controller) {
                _controller.complete(controller);
              },
            ),
          ),
        ),
      )
    );
  }
}

Full test project can be found here: https://github.com/jamespfinn/flutter_maps_clip_test
Be sure to set your maps api key.

Metadata

Metadata

Assignees

Labels

p: mapsGoogle Maps pluginpackageflutter/packages repository. See also p: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions