FixedCoordinates.php in Geolocation Field 8.3
File
src/Plugin/geolocation/Location/FixedCoordinates.php
View source
<?php
namespace Drupal\geolocation\Plugin\geolocation\Location;
use Drupal\geolocation\LocationInterface;
use Drupal\geolocation\LocationBase;
class FixedCoordinates extends LocationBase implements LocationInterface {
public static function getDefaultSettings() {
return [
'latitude' => '',
'longitude' => '',
];
}
public function getSettingsForm($option_id = NULL, array $settings = [], $context = NULL) {
$settings = $this
->getSettings($settings);
$form = [
'latitude' => [
'#type' => 'textfield',
'#title' => $this
->t('Latitude'),
'#default_value' => $settings['latitude'],
'#size' => 60,
'#maxlength' => 128,
],
'longitude' => [
'#type' => 'textfield',
'#title' => $this
->t('Longitude'),
'#default_value' => $settings['longitude'],
'#size' => 60,
'#maxlength' => 128,
],
];
return $form;
}
public function getCoordinates($center_option_id, array $center_option_settings, $context = NULL) {
$settings = $this
->getSettings($center_option_settings);
return [
'lat' => (double) $settings['latitude'],
'lng' => (double) $settings['longitude'],
];
}
}