map_type_picker 1.0.4 copy "map_type_picker: ^1.0.4" to clipboard
map_type_picker: ^1.0.4 copied to clipboard

Easily change between map types when using Platform Maps.

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.

0
likes
70
pub points
0%
popularity

Publisher

unverified uploader

Easily change between map types when using Platform Maps.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, platform_maps_flutter

More

Packages that depend on map_type_picker