カテゴリー・パッケージ・リポジトリを検索

google_maps_routes のカバー
パッケージ詳細v1.1.2

google_maps_routes

Google ディレクション API を使用して、Google マップにルートを描画するためのパッケージ。

AndroidiOSWeb
30日間ダウンロード
850
いいね数
29
Pub ポイント
140

パッケージをインストール

flutter pub add google_maps_routes

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Google Directions API を使用して Google マップにルートを描画できる Flutter パッケージです。場所間の経路情報を取得・レンダリングすることで、ルートの可視化を簡素化し、Android、iOS、Web プラットフォームでリアルタイムナビゲーションパスをサポートします。Google Maps for Flutter とシームレスに統合され、開発者がポリラインルート、経由地点、移動詳細を表示できるようになります。ターンバイターンナビゲーションや位置ベースのルーティング機能が必要なアプリに最適です。

用途

  • 運転経路の表示
  • 歩行または自転車のルートを可視化する
  • ステップバイステップナビゲーションの統合
  • 配達またはライドシェアリングアプリの構築
  • 旅行イタineraryプランナーの作成

主な機能

  • ポリラインを使用したルートの描画
  • 複数の経由地点のサポート
  • Google Directions API との統合
  • クロスプラットフォーム互換性(Android、iOS、Web)
  • 最小限の構成で簡単なセットアップ

適している対象

  • ナビゲーションアプリ開発者
  • 物流および配達アプリケーション
  • 旅行と観光アプリ
  • 場所ベースのサービスプラットフォーム
  • 動的ルートレンダリングを必要とするアプリ

注意事項

  • 有効なGoogle Maps APIキーが必要です
  • インターネット接続に依存します
  • Google Directions API の利用コストが発生する可能性があります
  • Google マッププラットフォームに限定
  • APIの利用レベルに応じてレート制限が適用されます

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

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

カテゴリー

依存関係

依存関係一覧 2 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。