jansuchanek/ndistance
最新稳定版本:v1.0.0
Composer 安装命令:
composer require jansuchanek/ndistance
包简介
Geocoding + driving distance via Nominatim/OSRM — no API key needed
README 文档
README
Address geocoding + driving distance calculation using free APIs. No API key needed.
- Nominatim (OpenStreetMap) — address → lat/lng
- OSRM — driving distance & duration
Installation
composer require jansuchanek/ndistance
Usage
use NDistance\DistanceCalculator; $calc = new DistanceCalculator( userAgent: 'MyApp/1.0', defaultCountry: 'cz', ); // Geocode address $coords = $calc->geocode('Brno, Česko'); // ['lat' => 49.19, 'lng' => 16.61] // Driving distance between coordinates $route = $calc->drivingDistance(50.08, 14.42, 49.19, 16.61); // ['distance' => 205.3, 'duration' => 125] (km, minutes) // Check delivery range $result = $calc->checkDistance(50.08, 14.42, 'Brno', 250.0); // ['ok' => true, 'distance' => 205.3, 'duration' => 125, ...]
Requirements
- PHP >= 8.1
- ext-curl
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-19