Skip to content

Mike-3/flutter_map_tappable_polyline

This branch is 1 commit ahead of OwnWeb/flutter_map_tappable_polyline:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

45dee16 Β· Aug 12, 2024

History

84 Commits
Oct 31, 2023
Jul 19, 2021
Oct 31, 2023
Oct 31, 2023
Jan 17, 2020
Jan 17, 2020
Aug 12, 2024
Jul 19, 2021
Oct 31, 2023
Aug 3, 2020
Oct 31, 2023
Aug 12, 2024

Repository files navigation

Flutter Map Tappable Polyline

pub package

A Polyline with onTap event listener
This is a plugin for flutter_map package

Usage

Add flutter_map and flutter_map_tappable_polyline to your pubspec:

dependencies:
  flutter_map: ^6.0.1
  flutter_map_tappable_polyline: any # take latest version on Pub

Add it in you FlutterMap and configure it using TappablePolylineLayerOptions.

  Widget build(BuildContext context) {
    return FlutterMap(
      options: new MapOptions(
        plugins: [
          TappablePolylineMapPlugin(),
        ],
      ),
      layers: [
        TileLayerOptions(
          urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
          subdomains: ['a', 'b', 'c'],
        ),
        TappablePolylineLayerOptions(
          // Will only render visible polylines, increasing performance
          polylineCulling: true,
          polylines: [
            TaggedPolyline(
              tag: "My Polyline", // An optional tag to distinguish polylines in `onTap` callback
              // ...all other Polyline options
            ),
          ],
          onTap: (polylines, tapPosition) => print('Tapped: ' +
            polylines.map((polyline) => polyline.tag).join(',') +
            ' at ' +
            tapPosition.globalPosition.toString()),
          onMiss: (tapPosition) {
            print('No polyline was tapped at position ' +
                tapPosition.globalPosition.toString());
          }
        )
      ],
    );
  }

About

A tappable Polyline plugin for flutter_map

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 98.9%
  • Other 1.1%