geocoder-php/google-maps-places-provider 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

geocoder-php/google-maps-places-provider

Composer 安装命令:

composer require geocoder-php/google-maps-places-provider

包简介

Geocoder Google Maps Places adapter

README 文档

README

Build Status Latest Stable Version Total Downloads Monthly Downloads Code Coverage Quality Score Software License

This is the Google Places provider from the PHP Geocoder. This is a READ ONLY repository. See the main repo for information and documentation.

Install

composer require geocoder-php/google-maps-places-provider

API Documentation

https://developers.google.com/places/web-service

Usage

This provider often requires extra data when making queries, due to requirements of the underlying Places API.

Geocoding

This provider supports two different modes of geocoding by text.

Find Mode

This is the default mode. It required an exact places name. It's not very forgiving, and generally only returns a single result

$results = $provider->geocodeQuery(
    GeocodeQuery::create('Museum of Contemporary Art Australia')
);

Search Mode

This mode will perform a search based on the input text. It's a lot more forgiving that the find mode, but results will contain all fields and thus be billed at the highest rate.

$results = $provider->geocodeQuery(
    GeocodeQuery::create('art museum sydney')
        ->withData('mode', GoogleMapsPlaces::GEOCODE_MODE_SEARCH)
);

around location (which is similar to reverse geocoding, see below):

$results = $provider->geocodeQuery(
    GeocodeQuery::create('bar')
        ->withData('mode', GoogleMapsPlaces::GEOCODE_MODE_SEARCH)
        ->withData('location', '-32.926642, 151.783026')
);

country matches a country name or a two letter ISO 3166-1 country code. If you only use the "region" parameter, you will not be guaranteed to have results on the region, as the documentation indicates Region:

The region parameter will only influence, not fully restrict, results from the geocoder.

$results = $provider->geocodeQuery(
    GeocodeQuery::create('montpellier')
        ->withData('components', 'country:FR');
);

Reverse Geocoding

Three options available for reverse geocoding of latlon coordinates:

  • mode search + type (e.g.) bar: uses Google Place API Text search, requires type
    • is similar to: Search around location (see previous section)
  • mode nearby + rankby distance: uses Google Place API Nearby search, requires type/keyword/name
  • mode nearby + rankby prominence: uses Google Place API Nearby search, requires radius

Default mode: search (because of backward compatibility). When using mode nearby default rankby: prominence. Mode search + type and mode nearby + type/keyword/name are very similar. Mode search gives formatted_address, mode nearby gives vicinity instead. E.g.:

  • search: has "formatted_address": "7 Cope St, Redfern NSW 2016"
  • nearby: has "vicinity" instead: "7 Cope St, Redfern"

Examples

$results = $provider->reverseQuery(
    ReverseQuery::fromCoordinates(-33.892674, 151.200727)
        // ->withData('mode', GoogleMapsPlaces::GEOCODE_MODE_SEARCH) // =default
        ->withData('type', 'bar') // requires type
    );
$address = $results->first()->getFormattedAddress();
$results = $provider->reverseQuery(
    ReverseQuery::fromCoordinates(-33.892674, 151.200727)
        ->withData('mode', GoogleMapsPlaces::GEOCODE_MODE_NEARBY)
        //->withData('rankby','prominence'); // =default
        ->withData('radius', 500) // requires radius (meters)
    );
$vicinity = $results->first()->getVicinity();
$results = $provider->reverseQuery(
    ReverseQuery::fromCoordinates(-33.892674, 151.200727)
        ->withData('mode', GoogleMapsPlaces::GEOCODE_MODE_NEARBY)
        ->withData('rankby','distance');
        ->withData('keyword', 'bar') // requires type/keyword/name
    );

Contribute

Contributions are very welcome! Send a pull request to the main repository or report any issues you find on the issue tracker.

geocoder-php/google-maps-places-provider 适用场景与选型建议

geocoder-php/google-maps-places-provider 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 711.38k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2019 年 08 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 geocoder-php/google-maps-places-provider 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 geocoder-php/google-maps-places-provider 我们能提供哪些服务?
定制开发 / 二次开发

基于 geocoder-php/google-maps-places-provider 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 711.38k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 23
  • 依赖项目数: 13
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 3
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-08-14