geocoder-php / google-maps-provider
GoogleMaps 地理编码适配器
4.7.1
2023-04-14 11:13 UTC
Requires
- php: ^7.4 || ^8.0
- geocoder-php/common-http: ^4.0
- willdurand/geocoder: ^4.0
Requires (Dev)
- geocoder-php/provider-integration-tests: ^1.0
- php-http/curl-client: ^2.2
- php-http/message: ^1.0
- phpunit/phpunit: ^9.5
Provides
This package is auto-updated.
Last update: 2024-09-18 19:18:11 UTC
README
这是 PHP 地理编码的 Google Maps 提供者。这是一个只读仓库。有关信息和文档,请参阅主仓库。
使用方法
$httpClient = new \Http\Discovery\Psr18Client(); // You must provide an API key $provider = new \Geocoder\Provider\GoogleMaps\GoogleMaps($httpClient, null, 'your-api-key'); $result = $geocoder->geocodeQuery(GeocodeQuery::create('Buckingham Palace, London'));
所有请求都需要有效的 API 密钥,但 Google 提供了一个免费层。请参阅此页面以获取获取 API 密钥的信息。
Google Maps for Business
以前,Google 提供了其 API 的“商业”版本。该服务已被弃用,但现有客户可以使用提供者上的静态 business
方法来创建客户端。
$httpClient = new \Http\Discovery\Psr18Client(); // Client ID is required. Private key is optional. $provider = \Geocoder\Provider\GoogleMaps\GoogleMaps::business($httpClient, 'your-client-id', 'your-private-key'); $result = $geocoder->geocodeQuery(GeocodeQuery::create('Buckingham Palace, London'));
安装
composer require geocoder-php/google-maps-provider