Skip to content

Not an issue: using google_maps_flutter tiles with flutter_map #1140

@Ahmed-gubara

Description

@Ahmed-gubara

Hi
Just had some time to play with google_maps_flutter package.
I would like to share a code that worked for me to use GoogleMap Widget as a tile layer on flutter_map

gist: google_tile_layer_widget.dart

usage:

Widget build(BuildContext context) {
    return Scaffold(
        body: FlutterMap(
      options: MapOptions(
        center: LatLng(51.5, -0.09),
        maxZoom: 21,
        interactiveFlags:
            InteractiveFlag.pinchZoom | InteractiveFlag.doubleTapZoom | InteractiveFlag.drag | InteractiveFlag.flingAnimation | InteractiveFlag.pinchMove,
        zoom: 13.0,
      ),
      children: [
        GoogleMapTileLayerWidget(options: GoogleMapTileLayerOptions(useAndroidViewSurface: true)),
        MarkerLayerWidget(
            options: MarkerLayerOptions(
          markers: [
            Marker(width: 80.0, height: 80.0, point: LatLng(51.5, -0.09), builder: (ctx) => const FlutterLogo()),
          ],
        )),
      ],
    ));
  }

There is a slight delay while panning, but it can be reduced greatly with useAndroidViewSurface: true

Metadata

Metadata

Assignees

No one assigned

    Labels

    general[DEPRECATED] This issue is better suited for Discussions or Discord

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions