ipowerful/googleplace
Composer 安装命令:
composer require ipowerful/googleplace
包简介
Google Places API library
README 文档
README
Location aware web application uses google-places-api(Place Search, Place Details, Geocoding , Distance Matrix, Timezone, Elevation ) a lot. They are not linked to each other also its hard to find a easy and time saving php libraray to work with these api. These libraray will need less knowldege about google api and give you flavour of OOP.
Setting
Add this line on your composer.json
"require":{ "digitaldream/googleplace":"1.*" }
You need to set your google api keys on top of your page. Like below
\GooglePlace\Request::$api_key = 'YOUR_GOOGLE_PLACES_API_KEY';
Nearby Search
A Nearby Search lets you search for places within a specified area. For example you can search all the Restaurents of your city.
$rankBy = new \GooglePlace\Services\Nearby([ 'location' => '23.823168,90.367728', 'rankby' => 'distance', 'type' => 'bank' ] ); $rankBy->places(); // it will return \Collection each contains a object of GooglePlace\Services\Place /* Google Return 60 places divide by 20 each request. To get next 20 result you have to call nextPage method. */ print_r($rankBy->nextPage()); // it will return \GooglePlace\Response
Text Search
Text Search Service is a web service that returns information about a set of places based on a string — for example "pizza in New York"
$textSearch = new \GooglePlace\Services\TextSearch([ 'query' => 'Restaurants in Mirpur' ]); $places = $textSearch->places(); //same as nearby
Place Details
A Place Details request returns more comprehensive information about the indicated place such as its complete address, phone number, user rating and reviews. You need to pass place_id or a reference from a Place Search
$place=new \GooglePlace\Services\Place([ 'placeid'=>'any place id' ]); $place->get(); echo $place->address(); echo $place->phone(); print_r($place->photos()); // returns Collection each contains a GooglePlace\Helpers\PlacePhoto object print_r($place->reviews()); // return Collection print_r($place->timezone(true)); // return Timezone API response print_r($place->distance($place2)); // return Distance Matrix API response print_r($place->elevation()); // return Elevation API response
Geocoding
You can get places by a place name or latitude and longitude.
$geocoding = new \GooglePlace\Services\Geocoding([ 'address' => 'House 13,Road 10,Section 11,Mirpur,Dhaka' ]); print_r($geocoding->places()); $reverseGeocoding= new \GooglePlace\Services\Geocoding([ 'address' => 'latlng' => '23.8163589,90.3709893' ]); print_r($reverseGeocoding->places()); //same as nearby
Distance Matrix API
Distance Matrix API is a service that provides travel distance and time for a matrix of origins and destinations, based on the recommended route between start and end points
$distanceMatrix = new \GooglePlace\Services\DistanceMatrix([ 'origins' => ['Dhaka University, Dhaka'], 'destinations' => ['National University of Bangldesh, Gazipur']]); print_r($distanceMatrix->calculate());
Timezone API
Time Zone API provides time offset data for locations on the surface of the earth. The API returns the name of that time zone, the time offset from UTC, and the daylight savings offset.
$timezone= new \GooglePlace\Services\Timezone([ 'location'=>'23.8163589,90.3709893', timestamp=time() ]) $response=$timezone->get(); echo $response->timeZoneId // return Asia/Dhaka
Elevation API
Get the altitude(height from sea level in meters) of a given place.
$elevation =new \GooglePlace\Services\Elevation([ 'locations'=>'23.8163589,90.3709893' ]); print_r($elevation->get());
ipowerful/googleplace 适用场景与选型建议
ipowerful/googleplace 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 08 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ipowerful/googleplace 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ipowerful/googleplace 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-08-18