bodunde/geocoder
Composer 安装命令:
composer require bodunde/geocoder
包简介
A laravel package that helps you with geocoding addresses and reverse geocoding coordinates using the google maps api. It also helps in calculating the distance between two locations using the Hervasine formula and the coordinates of the locations
README 文档
README
A Laravel Package that interfaces with the google maps API to help convert a plain address to longitude and latitude coordinates and vice-versa. It can also calculate the distance (in kilometers or miles) between two locations using their coordinates.
Installation
- include the package in your
composer.jsonfile and runcomposer updateor runcomposer require bodunde/geocoderor you can do it oldschool and just clone the repo and include it in your application. - navigate to your
configdirectory in your laravel application and locate theapp.phpfile - add this line to your service provide
Bodunde\GoogleGeocoder\GeocoderServiceProvider::class - publish its config file by running
php artisan vendor:publish - include your
google_api_keyingeocoder.phpfile located in the config directory Voila!!! You are done
Usage
<?php namespace Your\Namespace; use Bodunde\GoogleGeocoder\Geocoder; ... ... // using dependency injection public function index(Geocoder $geocoder) { // get coordinates $coordinates = $geocoder->getCoordinates('55 Moleye Street, Yaba'); // get address via reverse geocoding $addressCoordinates = [ "lat" => 6.5349646, "lng" => 3.3892894 ]; $address = $geocoder->getAddress($addressCoordinates); // get distance between two locations $location1 = [ "lat" => 6.5349646, "lng" => 3.3892894 ]; $location2 = [ "lat" => 6.601838, "lng" => 3.3514863 ]; $distance = $geocoder->getDistanceBetween($location1, $location2); /** geocoder can also be instantiated normally without DI */ //e.g $geocoder = new Geocoder; }
Tests
In the package root run phpunit
bodunde/geocoder 适用场景与选型建议
bodunde/geocoder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.73k 次下载、GitHub Stars 达 24, 最近一次更新时间为 2016 年 10 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 bodunde/geocoder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bodunde/geocoder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 7.73k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 24
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-10-09