Search categories, packages and repositories

google_maps_routes cover
Package detailsv1.1.2

google_maps_routes

A package for drawing routes on Google Maps by using the Google Directions API.

AndroidiOSWeb
30-day downloads
850
Likes
29
Pub points
140

Install package

flutter pub add google_maps_routes

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Flutter package that enables drawing routes on Google Maps using the Google Directions API. It simplifies route visualization by fetching and rendering directions between locations, supporting real-time navigation paths on Android, iOS, and web platforms. The package integrates seamlessly with Google Maps for Flutter, allowing developers to display polyline routes, waypoints, and travel details. Ideal for apps requiring turn-by-turn navigation or location-based routing features.

Use cases

  • Displaying driving directions
  • Visualizing walking or cycling routes
  • Integrating turn-by-turn navigation
  • Building delivery or ride-sharing apps
  • Creating travel itinerary planners

Key features

  • Route drawing with polylines
  • Support for multiple waypoints
  • Integration with Google Directions API
  • Cross-platform compatibility (Android, iOS, Web)
  • Easy setup with minimal configuration

Suitable for

  • Navigation app developers
  • Logistics and delivery applications
  • Travel and tourism apps
  • Location-based service platforms
  • Apps requiring dynamic route rendering

Considerations

  • Requires a valid Google Maps API key
  • Depends on internet connectivity
  • May incur usage costs from Google Directions API
  • Limited to Google Maps platform
  • Rate limits apply based on API usage tier

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

google_maps_routes

This is a package for creating routes on google maps using the directions API from Google. Routes are drawn with help of the flutter_polyline_points package.

Screenshot

example-route

Usage

To use the google_maps_routes package, first depend on it.

Then import it where you want to use it

import 'package:google_maps_routes/google_maps_routes.dart';

To use it you need a List of points like this:

/// LatLng is included in google_maps_flutter
List<LatLng> points = [
    LatLng(latitude, longitude),
    LatLng(latitude, longitude),
    LatLng(latitude, longitude),
    LatLng(latitude, longitude),
];

Then you need to instantiate this plugin

MapsRoutes route = new MapsRoutes();

To create a route, just call the following function:

/// routeName is a string and can be anything; it can include spaces but
/// they will be replaced with a dash
/// example: 'Example route' turns into 'Example-route'

/// color is a Color type and will be used as the polyline color:
/// example: Color.fromRGBO(130, 78, 210, 1.0)

/// googleApyKey is a string and is a google directions API key
/// example: get it at
/// https://developers.google.com/maps/documentation/directions/get-api-key
await route.drawRoute(points, routeName, color, googleApiKey);

To use a different travel mode, use the travelMode parameter.

/// Options: driving, bicycling, transit, walking
await route.drawRoute(
    points,
    routeName,
    color,
    googleApiKey,
    travelMode: TravelModes.walking
);

To display the polylines you need to add a polylines parameter to your google map widget.

GoogleMap(polylines: route.routes),

If you ever want to clear the routes, just call:

route.routes.clear();

If you want to calculate the distance of the route use you call the following function with the same List of points you used for drawing the route. You can also use it by itself.

/// Initialize a calculator
DistanceCalculator distanceCalculator = new DistanceCalculator();

/// Call a function that returns a string
/// Pass it the List of points
/// By default it will return with 1 decimal point but you can pass an 
/// option that changes that 
distanceCalculator.calculateRouteDistance(points, decimals: 1);
Credits

Categories

Dependencies

Dependency list 2 items

Source repository

Projects using this package

No data available yet.