google_directions_api 套件為 Google Directions API 提供了 Flutter 界面,讓開發者能使用各種運輸模式(如駕車、步行、騎自行車和大眾運輸)在地點之間計算路線。它支援多個平台,包括 Android、iOS、Web、macOS、Windows 和 Linux。該套件簡化了與 Google 路由服務的整合,讓應用程式能夠顯示逐步導航、行程時間估計和距離計算。它非常適合需要路線資料的導航、行程規劃和基於位置的應用程式。
適用情境
導航應用
行程規劃功能
配送路線優化
基於位置的服務增強
即時交通方向查詢
主要特色
支援多種傳輸模式
跨平台相容性
簡單的 API 結合
路線距離與時程計算
逐向導航指引支援
適合對象
開發導航工具的開發者
需要路線規劃的應用
旅行與物流應用
行動與Web位置服務
整合 Google 地圖路徑規劃功能
使用建議
需要 Google Cloud Platform API 金鑰
根據使用情況應用速率限制
大量使用時可能會產生額外費用
即時資料需要網路連接
需要正確處理API錯誤回應
原始 README
以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。
google_directions_api
The Directions API is a service that calculates directions between locations. You can search for directions for several modes of transportation, including transit, driving, walking, or cycling.
Getting Started
The Directions API is a service that calculates directions between locations using an HTTP request.
With the Directions API, you can:
Search for directions for several modes of transportation, including transit, driving, walking or cycling.
Return multi-part directions using a series of waypoints.
Specify origins, destinations, and waypoints as text strings (e.g. "Chicago, IL" or "Darwin, NT, Australia"), or as latitude/longitude coordinates, or as place IDs.
The API returns the most efficient routes when calculating directions. Travel time is the primary factor optimized, but the API may also take into account other factors such as distance, number of turns and many more when deciding which route is the most efficient.
Note: This service is not designed to respond in real time to user input.
For full info about Directions API visit official documentation
Usage
import'package:google_directions_api/google_directions_api.dart';
voidmain() {
DirectionsService.init('API_KEY');
final directionsService = DirectionsService();
final request = DirectionsRequest(
origin: 'New York',
destination: 'San Francisco',
travelMode: TravelMode.driving,
);
directionsService.route(request,
(DirectionsResult response, DirectionsStatus status) {
if (status == DirectionsStatus.ok) {
// do something with successful response
} else {
// do something with error response
}
});
}
Feature requests and Bug reports
Feel free to post a feature requests or report a bug here.