パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v3.0.2

gmaps_by_road_distance_calculator

これは、マップ上の1点から別の点までの道路距離を計算するためのパッケージです。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
135
いいね数
14
Pub ポイント
120

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

flutter pub add gmaps_by_road_distance_calculator

パッケージ概要

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

このFlutterパッケージはGoogleマップデータを使用して、2つの地理的位置間の道路ベースの距離を計算します。実際の道路ネットワークを利用することで、正確な移動距離とルート推定が可能になり、ナビゲーションや物流アプリケーションに最適です。Android、iOS、Web、macOS、Windows、Linuxなど複数のプラットフォームをサポートしており、広範な互換性を確保しています。簡単なコマンドライン追加により、開発者は容易に統合できます。本パッケージは、直線距離(空から飛ぶように)ではなく、実際の道路経路に基づいた正確でリアルタイムの距離計算が必要な用途に特化しています。

用途

  • ナビゲーションアプリ
  • 物流および配達状況の追跡
  • ルート計画ツール
  • 移動時間の推定
  • 地図における距離ベースのフィルタリング

主な機能

  • 道路距離の計算
  • マルチプラットフォーム対応
  • Google マップの統合
  • シンプルな API インターフェース
  • リアルタイム距離の更新

適している対象

  • ナビゲーション機能を構築している開発者
  • 正確な旅行距離が必要なアプリ
  • クロスプラットフォーム地図アプリケーション
  • 配達およびライドシェアリングサービス
  • 場所に応じた分析

注意事項

  • API呼び出しにはインターネット接続が必要です
  • Google Mapsのバックエンドの利用可能性に依存します
  • 大量のリクエストで利用コストが発生する可能性があります
  • Googleマップが提供する道路ネットワークデータに限定

元の README

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

gmaps_by_road_distance_calculator

A Dart package for calculating distances along roads and routes using multiple APIs and formats.

Features

  • Calculate distances between geographical points
  • Support for real-time distance tracking
  • Calculate distances along roads using OSRM (Open Source Routing Machine)
  • Multiple travel modes: driving, bicycling, walking, transit
  • Parse and work with GPX and KML route files
  • Decode polyline strings to geographical points

Getting Started

Installation

Add the package to your pubspec.yaml:

dependencies:
  gmaps_by_road_distance_calculator: ^1.0.0

Then run:

flutter pub get
Import
import 'package:gmaps_by_road_distance_calculator/gmaps_by_road_distance_calculator.dart';

Usage

Basic Distance Calculation

Calculate straight-line distances between geographical points:

final calculator = ByRoadDistanceCalculator();
final points = [
  LatLng(37.7749, -122.4194), // San Francisco
  LatLng(34.0522, -118.2437), // Los Angeles
];

// Calculate straight-line distance in kilometers
final distance = calculator.calculateDistance(points);
print('Distance: $distance km');
Calculate Road Distance Using OSRM

Calculate actual road distance between two points using the OSRM service:

final calculator = ByRoadDistanceCalculator();
final start = LatLng(37.7749, -122.4194); // San Francisco
final end = LatLng(34.0522, -118.2437); // Los Angeles

// Calculate driving distance
calculator.calculateDistanceViaOSRM(
  start: start,
  end: end,
  mode: TravelModes.driving,
).then((result) {
  print('Driving distance: ${result.distance} km');
  print('Route consists of ${result.points.length} points');
});

// Calculate walking distance
calculator.calculateDistanceViaOSRM(
  start: start,
  end: end,
  mode: TravelModes.walking,
).then((result) {
  print('Walking distance: ${result.distance} km');
});
Real-time Distance Tracking

Track and update distance in real-time as new points are added:

final calculator = ByRoadDistanceCalculator();

// Listen for distance updates
calculator.distanceUpdates.listen((distance) {
  print('Current distance: $distance km');
});

// Add points as they become available (e.g., from GPS)
calculator.addPoint(LatLng(37.7749, -122.4194));
calculator.addPoint(LatLng(37.7850, -122.4100));
calculator.addPoint(LatLng(37.7950, -122.4000));

// Reset tracking when needed
calculator.clearPoints();
Working with GPX Files

Parse GPX files to extract geographical points:

final calculator = ByRoadDistanceCalculator();
final gpxContent = '''
<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.1">
  <trk>
    <trkseg>
      <trkpt lat="37.7749" lon="-122.4194"></trkpt>
      <trkpt lat="37.7850" lon="-122.4100"></trkpt>
      <trkpt lat="37.7950" lon="-122.4000"></trkpt>
    </trkseg>
  </trk>
</gpx>
''';

final points = calculator.parseGPX(gpxContent);
final distance = calculator.calculateDistance(points);
print('Distance from GPX: $distance km');
Working with KML Files

Parse KML files to extract geographical points:

final calculator = ByRoadDistanceCalculator();
final kmlContent = '''
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <Placemark>
      <LineString>
        <coordinates>
          -122.4194,37.7749,0
          -122.4100,37.7850,0
          -122.4000,37.7950,0
        </coordinates>
      </LineString>
    </Placemark>
  </Document>
</kml>
''';

final points = calculator.parseKML(kmlContent);
final distance = calculator.calculateDistance(points);
print('Distance from KML: $distance km');
Decode Polyline Strings

Convert encoded polyline strings to geographical points:

final encodedPolyline = "_p~iF~ps|U_ulLnnqC_mqNvxq`@";
final points = ByRoadDistanceCalculator.decodePolylineString(encodedPolyline);

Advanced Configuration

Custom OSRM Server

You can specify a custom OSRM server URL if you're hosting your own instance:

calculator.calculateDistanceViaOSRM(
  start: start,
  end: end,
  mode: TravelModes.driving,
  customOSRMUrl: 'https://your-custom-osrm-server.com/route/v1',
).then((result) {
  print('Distance: ${result.distance} km');
});

Dependencies

This package depends on:

  • latlong2: For geographical coordinate operations
  • http: For API requests
  • xml: For parsing GPX and KML files

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Issues and Feedback

Please file issues and feedback here.

カテゴリー

依存関係

依存関係一覧 4 件

ソースリポジトリ

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

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