Finger Route
This example demonstrates how to create a Flutter app that allows users to draw a route on a map using their finger, calculates the route based on the drawn waypoints, and displays it using the Maps SDK for Flutter.
How It Works
The example app demonstrates the following features:
- Allow users to draw a route on the map with their finger.
- Calculate a route based on the drawn waypoints.
- Display the route on a map and provide options to cancel or clear the routes.
UI and Map Integration
This code sets up the basic structure of the app, including the map and the app bar. It also provides buttons in the app bar for drawing, building, canceling, and clearing routes.
Drawing and Route Calculation
This code handles drawing waypoints on the map, calculating the route based on those waypoints, and provides options to cancel or clear the routes. The map is centered on the calculated routes, and a label showing the distance and duration is displayed.
Displaying Route Information
This code defines an extension on the Route class that calculates and formats the distance and duration of the route for display on the map.