MapCenterBase.php in Geolocation Field 8.2
File
src/MapCenterBase.php
View source
<?php
namespace Drupal\geolocation;
use Drupal\Core\Plugin\PluginBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Form\FormStateInterface;
abstract class MapCenterBase extends PluginBase implements MapCenterInterface, ContainerFactoryPluginInterface {
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition);
}
public static function getDefaultSettings() {
return [];
}
public function getSettings(array $settings) {
$default_settings = $this
->getDefaultSettings();
$settings = array_replace_recursive($default_settings, $settings);
return $settings;
}
public function getSettingsForm($option_id = NULL, array $settings = [], $context = NULL) {
$form = [];
return $form;
}
public function validateSettingsForm(array $values, FormStateInterface $form_state) {
}
public function getAvailableMapCenterOptions($context) {
return [
$this
->getPluginId() => $this
->getPluginDefinition()['name'],
];
}
public function alterMap(array $map, $center_option_id, array $center_option_settings, $context = NULL) {
$map['#centre'] = [
'lat' => 0,
'lng' => 0,
];
return $map;
}
}