Dart package that creates a custom picker to easily change between map types when using Platform Maps in your app.

Features

Use a Stack widget to overlay the map type picker ontop of a Platform Map, then easily switch between different map types. Map type picker colors are completly customizable. map-switching-type-with-picker

Getting started

The platform_maps_flutter package must be imported into your project before using the map_type_picker package

Usage

  1. Set starting map type in your Widget initState
@override
  void initState() {
    MapTypePicker.mapType = MapType.normal; // Here, options are .normal, .hybrid, .satellite
    super.initState();
  }
  1. Set Platform Map mapType to variable set in initState
PlatformMap(
            mapType: MapTypePicker.mapType, // Here
            initialCameraPosition: const CameraPosition(
              target: LatLng(51.507391, -0.1277),
              zoom: 10.0,
            ))
  1. In the same class as the Map Type Picker, create a refresh function to update parent Platform Map state from child MapTypePicker
refresh() {
    setState(() {});
  }
  1. Overlay Platform Map with Map Type Picker widget, pass the refresh function in the notifyParent argument
MapTypePicker(notifyParent: refresh)

Additional information

See example for full sample app implementing the Map Type Picker widget.

Libraries

map_type_picker