用于使用谷歌的街景、地图、距离... API的辅助工具

dev-master 2020-10-21 13:49 UTC

This package is auto-updated.

Last update: 2024-09-24 16:08:00 UTC


README

Google\Position

new Google\Position(
	bool $throw_exceptions_on_error = true,
	bool $log_errors = true,
	string $api_key = Config::get('google','api_key')
)

地理编码

(new Google\Position)
	->setAddress('Place Charges de Gaulle, 75008 Paris, France')
	->getPosition(); // array

更多选项

->getLatitude() // float
->getLongitude() // float

反向地理编码

(new Google\Position)
	->setPosition(
		48.8737917, 
		2.2950275
	)
	->getAddress(); // string

更多选项

->getStreet() // string
->getStreetNumber() // string
->getZipCode()  // string
->getCity() // string
->getCountry() // string

Google\Photo

  • 从街景检索照片URL
$photo_url = (new \Google\Photo)
//	->position($lat,$lnt)
	->option(['key'=>'YourGoogleApiKeyHere'])
	->address('Some normal address')
	->size(500,500)
	->url();

Google\Map

  • 获取带有标记的静态地图URL
$map_url = (new \Google\Map)
	->option(['key'=>'YourGoogleApiKeyHere'])
	->center($lat, $lng);
	->zoom(7)
	->retina(true)
	->marker($lat, $lng)
	->size(600,600)
	->url();