pnlinh / laravel-google-distance
在Laravel中计算Google距离矩阵API
v1.0.9
2023-01-10 16:47 UTC
Requires
- php: ^7.1.3|^7.3|^8.0
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- mockery/mockery: ^1.0
- orchestra/testbench: ^4.0
- phpunit/phpunit: ^8.0|^9.3.3
README
需求
- PHP >= 7.1.3
- Laravel >= 5.5.*
安装
使用composer安装此包。
composer require pnlinh/laravel-google-distance
为了发布配置 config/google-distance.php
,使用以下命令
php artisan vendor:publish --tag="google-distance"
您必须在.env文件中设置您的 Google Maps API密钥 GOOGLE_MAPS_DISTANCE_API_KEY,如下所示
GOOGLE_MAPS_DISTANCE_API_KEY=ThisIsMyGoogleApiKey GOOGLE_MAPS_DISTANCE_UNITS=ThisIsUnits
使用方法
// Use Facades use Pnlinh\GoogleDistance\Facades\GoogleDistance; $distance = GoogleDistance::calculate('FromAddress', 'To Address'); // Use Helper Function $distance = google_distance('From Address', 'To Address');
测试
composer test
致谢
更多信息,请访问 https://developers.google.com/maps/documentation/distance-matrix/