stanislav-janu / gps
适用于 nette 的 GPS 扩展
v3.0.0
2024-05-16 12:10 UTC
Requires
- php: >=8.0
- nette/utils: ^4.0
Requires (Dev)
- nette/tester: ^2.5
- rector/rector: ^1.0
- stanislav-janu/phpstan: ^1.0
README
具有有用检测和方法的 GPS 点。
安装
composer require stanislav-janu/gps
兼容性
使用方法
use JanuSoftware\GPS\GpsPoint; use JanuSoftware\GPS\GpsPointException; try { $point = GpsPoint::from('49°3\'6.630"N, 14°26\'7.763"E'); echo $point; // 49.0518417, 14.4354897 echo $point->lat; // 49.0518417 echo $point->lng; // 14.4354897 } catch (GpsPointException $exception) { echo $exception->getMessage(); }
接受格式
- 谷歌地图 URL
- Mapy.cz URL
- 49°3'6.630"N, 14°26'7.763"E
- N 49°3.11050', E 14°26.12938'
- 49.0518417N, 14.4354897E
- 49.0518417N,14.4354897E
- 49.0518417, 14.4354897
- 49.0518417,14.4354897
- 49.0518417 14.4354897
- -47.338388,-0.990228
- -47.338388 -0.990228
距离
$point1 = GpsPoint::from('some coordinates'); $point2 = GpsPoint::from('some coordinates'); $distance = $point1->distanceTo($point2); // distance in meters
谷歌地图距离矩阵
... $distance = $point1->distanceTo($point2, 'Google Maps API key'); // distance in meters