搜索插件、代码仓与 APP 分类

插件详情v1.0.8

routing_client_dart

用于路由客户端 API 的 Dart 包(支持 OSRM/Valhalla 项目)

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
6290
喜欢数
25
Pub 分数
130

安装插件

flutter pub add routing_client_dart

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Dart 包,为基于 OpenStreetMap 的路由引擎(如 OSRM 和 Valhalla)提供客户端路由功能。它使开发者能够将实时路线计算集成到跨平台应用程序中,支持 Android、iOS、Web、macOS、Windows 和 Linux。该包简化了与路由服务的 API 交互,提供了请求路线、处理响应和管理错误的简洁接口。非常适合需要高效路径查找的导航和位置感知应用。

适合场景

  • 实时路线规划
  • 导航应用开发
  • 地理空间数据分析
  • 多平台位置跟踪
  • 与 OSRM 或 Valhalla 服务器集成

主要特点

  • 支持 OSRM 和 Valhalla 路由 API
  • 跨平台兼容性
  • 简单的请求/响应处理
  • 错误容错
  • 轻量且易于集成

适合对象

  • 移动和网络导航应用
  • 物流和配送平台
  • 户外活动追踪工具
  • 基于位置的服务集成
  • 使用OpenStreetMap数据的开发者

使用建议

  • 需要外部 OSRM 或 Valhalla 服务器
  • 路由请求需要网络连接
  • 仅限基于OSM的路由提供商
  • 无内置地图渲染
  • 某些服务器可能需要身份验证

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Routing Client Dart Package

pub

Package for osm routing client api

we support routing API for osrm-backend

also Valhalla Route API (more APIs will be added )

openrouteservice (coming soon)

from 1.0.0 instruction will be included directly when requesting the route

you can use our osrm service or valhalla service directly insteado of our RoutingManager

client api support
  • OSRM Client Api
    • route service
    • trip service
  • Valhalla Client
    • route service API

Installing

Add the following to your pubspec.yaml file:

dependencies:
  routing_client_dart: ^1.0.7
example for osrm route service
    List<LngLat> waypoints = [
      LngLat(lng: 13.388860, lat: 52.517037),
      LngLat(lng: 13.397634, lat: 52.529407),
      LngLat(lng: 13.428555, lat: 52.523219),
    ];
    final manager = RoutingManager();
    final route = await manager.getRoute(
      OSRMRequest.route(
        waypoints: waypoints,
        geometries: Geometries.polyline,
        steps: true,
        languages: Languages.en,
      )
    );
example for osrm trip service
    List<LngLat> waypoints = [
      LngLat(lng: 13.388860, lat: 52.517037),
      LngLat(lng: 13.397634, lat: 52.529407),
      LngLat(lng: 13.428555, lat: 52.523219),
    ];
    final manager = RoutingManager();
    final road = await manager.getRoute(
      OSRMRequest.trip(
        waypoints: waypoints,
        destination: DestinationGeoPointOption.last,
        source: SourceGeoPointOption.first,
        geometries: Geometries.polyline,
        steps: true,
        languages: Languages.en,
        roundTrip:false,
      )
    );
example for check Location in Road
final currentLocation = LngLat.fromList(lnglat: [13.389147, 52.527549]);
    final isOnPath =
await roadManager.isOnPath(road, currentLocation, tolerance: 5);
Example to get next navigation instruction of current Location
final currentLocation = LngLat.fromList(lnglat: [13.389147, 52.527549]);
    final isOnPath =
final instruction = await roadManager.nextInstruction(instructions, road, currentLocation, tolerance: 5);

Warning the precision of LngLat should be 5 if the road contain polylineEncoded, or the same precies as LngLat in polylines

Note you can get some inaccurate information nextInstruction,for that we will be happy for yours contributions

Note you can get voice instruction for valhalla instruction

Note more documentation will be added to soon

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目