public function Location::alterMap in Geolocation Field 8.2
Same name and namespace in other branches
- 8.3 src/Plugin/geolocation/MapCenter/Location.php \Drupal\geolocation\Plugin\geolocation\MapCenter\Location::alterMap()
Alter map..
Parameters
array $map: Map object.
int $center_option_id: MapCenter option ID.
array $center_option_settings: The current feature settings.
mixed $context: Context like field formatter, field widget or view.
Return value
array Map object.
Overrides MapCenterBase::alterMap
File
- src/
Plugin/ geolocation/ MapCenter/ Location.php, line 87
Class
- Location
- Location based map center.
Namespace
Drupal\geolocation\Plugin\geolocation\MapCenterCode
public function alterMap(array $map, $center_option_id, array $center_option_settings, $context = NULL) {
if (!$this->locationManager
->hasDefinition($center_option_id)) {
return $map;
}
/** @var \Drupal\geolocation\LocationInterface $location */
$location = $this->locationManager
->createInstance($center_option_id);
$map_center = $location
->getCoordinates($center_option_id, $center_option_settings, $context);
if (empty($map_center)) {
return FALSE;
}
$map['#centre'] = $map_center;
return $map;
}