protected function GeocoderApiEnpoints::addGeometryProperty in Geocoder 8.2
Same name and namespace in other branches
- 8.3 src/Controller/GeocoderApiEnpoints.php \Drupal\geocoder\Controller\GeocoderApiEnpoints::addGeometryProperty()
Add a geometry property if not defined (as Google Maps Geocoding does).
Parameters
\Geocoder\Model\Address $address: The Address array.
Return value
array The Address Geometry Property.
1 call to GeocoderApiEnpoints::addGeometryProperty()
- GeocoderApiEnpoints::getAddressCollectionResponse in src/
Controller/ GeocoderApiEnpoints.php - Get Address Collection Response.
File
- src/
Controller/ GeocoderApiEnpoints.php, line 99
Class
- GeocoderApiEnpoints
- Class GeocoderApiEnpoints.
Namespace
Drupal\geocoder\ControllerCode
protected function addGeometryProperty(Address $address) {
/* @var array $address_array */
$address_array = $address
->toArray();
return [
'location' => [
'lat' => $address_array['latitude'],
'lng' => $address_array['longitude'],
],
'viewport' => [
'northeast' => [
'lat' => $address_array['bounds']['north'],
'lng' => $address_array['bounds']['east'],
],
'southwest' => [
'lat' => $address_array['bounds']['south'],
'lng' => $address_array['bounds']['west'],
],
],
];
}