从 Symfony Ivory Bundle 中的 Google 处 API 获取坐标
Get coordinates from Google places API in Symfony Ivory Bundle
我在一个 Symfony 项目中,我必须在其中为用户分配一个地址。然后我必须在地图上显示他们的位置。
我使用 Ivory Google Maps Bundle。标记与坐标一起使用。
所以我认为最好的方法是使用 Google Places 并获得
坐标。
然后将其分配给标记。
问题是:如何从 Google 个地方 API 获取坐标并用 doctrine 存储它们?
您的包可以查询 The Google Maps Geocoding API,它会为您提供有关地点的坐标信息。
// Requests the ivory google map geocoder service
$geocoder = $this->get('ivory_google_map.geocoder');
// Geocode an address
$response = $geocoder->geocode('YOUR_ADDRESS_HERE');
// Get the result corresponding to your address
foreach($response->getResults() as $result) {
var_dump($result->getGeometry()->getLocation());
}
这是 full doc !
我在一个 Symfony 项目中,我必须在其中为用户分配一个地址。然后我必须在地图上显示他们的位置。 我使用 Ivory Google Maps Bundle。标记与坐标一起使用。 所以我认为最好的方法是使用 Google Places 并获得 坐标。 然后将其分配给标记。
问题是:如何从 Google 个地方 API 获取坐标并用 doctrine 存储它们?
您的包可以查询 The Google Maps Geocoding API,它会为您提供有关地点的坐标信息。
// Requests the ivory google map geocoder service
$geocoder = $this->get('ivory_google_map.geocoder');
// Geocode an address
$response = $geocoder->geocode('YOUR_ADDRESS_HERE');
// Get the result corresponding to your address
foreach($response->getResults() as $result) {
var_dump($result->getGeometry()->getLocation());
}
这是 full doc !