rezzza / google-geocoder
此包已被弃用,不再维护。未建议替代包。
简单封装Google地理编码Web服务
v2.1
2016-01-04 15:23 UTC
Requires
- php: >=5.6.0
- egeloen/http-adapter: ~1.0
- jakeasmith/http_build_url: ^1.0
Requires (Dev)
- atoum/atoum: ~1.0
- atoum/stubs: ~2.1
This package is not auto-updated.
Last update: 2022-02-01 12:50:08 UTC
README
安装
$ composer require rezzza/google-geocoder
使用
您应该在您的仓库上自行构建
$googleAddressRepository = new Rezzza\GoogleGeocoder\GoogleAddressRepository( new Rezzza\GoogleGeocoder\GoogleGeocodeClient( new Ivory\HttpAdapter\CurlHttpAdapter(), 'YOUR_GOOGLE_API_KEY' ), new Rezzza\GoogleGeocoder\Model\AddressFactory );
然后您可以使用仓库中所有可用的方法
findByPlaceIdWithLanguage($placeId, $language)
findByCoordinatesWithLanguage($latitude, $longitude, $language)
findByAddressWithLanguage($address, $language)
findByLocalityAndCountryCodeWithLanguage($locality, $countryCode, $language)
findByLocalityAndCountryCodeAndAministrativeAreaWithLanguage($locality, $countryCode, $administrativeArea, $language)
所有这些方法都将返回一个 Rezzza\GoogleGeocoder\Model\AddressCollection
,除了第一个,它将直接返回一个 Rezzza\GoogleGeocoder\Model\Address
(因为placeId是唯一的)。