thiagoprz / here-geocoder
Laravel 用于探索 Here Maps API 的包
0.0.7
2020-11-03 19:47 UTC
Requires
- php: ^7.1.3
- guzzlehttp/guzzle: ^6.3 || ^7.0.1
Requires (Dev)
- estahn/phpunit-json-assertions: @stable
- orchestra/testbench: ^3.10@dev
- phpunit/phpunit: ^8.3@dev
README
用于与 Here Maps API 一起工作的 Laravel 包。
安装
composer require thiagoprz/here-geocoder
- 在 config/app.php 中添加提供者
'providers' => [
...
Thiagoprz\HereGeocoder\HereGeocoderServiceProvider::class,
...
]
- 在您的项目 .env 文件(或系统变量)中添加三个环境变量
- HERE_API_ID 用于地理定位服务
- HERE_APP_CODE 用于地理定位服务
- HERE_API_KEY 用于反向地理定位服务
在 https://developer.here.com/?create=Freemium-Basic&keepState=true&step=account 上注册并创建一个项目。
功能
- 地址(和地点)地理编码
$geocoder = new HereGeocoder();
$geocoder->geocode('Champ de Mars, 5 Avenue Anatole France, 75007 Paris');
// Returns
{"Response":{"MetaInfo":{"Timestamp":"2019-06-19T11:58:23.882+0000"},"View":[{"_type":"SearchResultsViewType","ViewId":0,"Result":[{"Relevance":0.72,"MatchLevel":"street","MatchQuality":{"Country":1,"City":1,"Street":[1],"PostalCode":1},"Location":{"LocationId":"NT_FuYSIyQ21HcHCtmZuSx09B","LocationType":"point","DisplayPosition":{"Latitude":48.85478,"Longitude":2.30038},"NavigationPosition":[{"Latitude":48.85478,"Longitude":2.30038}],"MapView":{"TopLeft":{"Latitude":48.85798,"Longitude":2.29497},"BottomRight":{"Latitude":48.85317,"Longitude":2.30242}},"Address":{"Label":"Champ-de-Mars, 75007 Paris, France","Country":"FRA","State":"\u00cele-de-France","County":"Paris","City":"Paris","District":"7e Arrondissement","Street":"Champ-de-Mars","PostalCode":"75007","AdditionalData":[{"value":"France","key":"CountryName"},{"value":"\u00cele-de-France","key":"StateName"},{"value":"Paris","key":"CountyName"}]}}}]}]}}
测试工具
为了使其更容易,Here Geocoder 包含一个用于测试地理编码功能的工具。安装后,访问 http://YOU_PROJECT_LOCAL_URL/here_geocoder,您将能够测试地理编码功能,而无需编写代码。
测试工具仅在 APP_ENV 不是在生产环境(prod 或 production)运行时才可用。
路线图
- 单元测试
- 添加批量地理定位支持
- 添加批量地点支持
- 添加 Facade 以简化对地理编码和未来方法的访问
有关地理编码 API 的更多信息,请参阅 Here API 文档:https://developer.here.com/documentation/geocoder/topics/what-is.html
HERE API 和 HERE 是 HERE Global B.V. 的商标。