private function IpGeoLocPluginStyleLeaflet::addMiniMapInset in IP Geolocation Views & Maps 8
Form part definition.
1 call to IpGeoLocPluginStyleLeaflet::addMiniMapInset()
- IpGeoLocPluginStyleLeaflet::buildOptionsForm in src/
Plugin/ views/ style/ IpGeoLocPluginStyleLeaflet.php - Provide a form to edit options for this plugin.
File
- src/
Plugin/ views/ style/ IpGeoLocPluginStyleLeaflet.php, line 643
Class
- IpGeoLocPluginStyleLeaflet
- Views Style plugin extension for Leaflet (if enabled).
Namespace
Drupal\ip_geoloc\Plugin\views\styleCode
private function addMiniMapInset(&$form, &$weight) {
$form['mini_map'] = [
'#title' => $this
->t('Mini-map inset'),
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => !empty($this->options['mini_map']['on']),
'#description' => $this
->t('A zoomed-out version of the main map as a mini-map inset in the bottom corner.'),
'#weight' => $weight++,
];
$form['mini_map']['on'] = [
'#title' => $this
->t('Enable mini-map inset'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['mini_map']['on']),
];
$form['mini_map']['height'] = [
'#title' => $this
->t('Height of inset'),
'#type' => 'textfield',
'#size' => 4,
'#field_suffix' => $this
->t('px'),
'#default_value' => $this->options['mini_map']['height'],
'#states' => [
'visible' => [
'input[name="style_options[mini_map][on]"]' => [
'checked' => TRUE,
],
],
],
];
$form['mini_map']['width'] = [
'#title' => $this
->t('Width of inset'),
'#type' => 'textfield',
'#size' => 4,
'#field_suffix' => $this
->t('px'),
'#default_value' => $this->options['mini_map']['width'],
'#states' => [
'visible' => [
'input[name="style_options[mini_map][on]"]' => [
'checked' => TRUE,
],
],
],
];
$form['mini_map']['toggle'] = [
'#title' => $this
->t('Allow visitor to minimise inset'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['mini_map']['toggle']),
'#states' => [
'visible' => [
'input[name="style_options[mini_map][on]"]' => [
'checked' => TRUE,
],
],
],
];
$form['mini_map']['scope_color'] = [
'#title' => $this
->t('Scope rectangle color'),
'#type' => 'textfield',
'#size' => 10,
'#default_value' => $this->options['mini_map']['scope_color'],
'#description' => $this
->t('<em>#rrggbb</em> or <a target="_colors" href="@url">color name</a>.', [
'@url' => 'http://www.w3schools.com/html/html_colornames.asp',
]),
// '@url' => url('http://www.w3schools.com/html/html_colornames.asp'))),
'#states' => [
'visible' => [
'input[name="style_options[mini_map][on]"]' => [
'checked' => TRUE,
],
],
],
];
$form['mini_map']['zoom_delta'] = [
'#title' => $this
->t('Zoom delta'),
'#type' => 'textfield',
'#size' => 3,
'#default_value' => $this->options['mini_map']['zoom_delta'],
'#description' => $this
->t('The difference between the zoom levels of main map and mini-map.'),
'#states' => [
'visible' => [
'input[name="style_options[mini_map][on]"]' => [
'checked' => TRUE,
],
],
],
];
// @ TODO find correct way to include this library
/*$lib_minimap = libraries_get_path('leaflet-minimap');
if ($lib_minimap) {
$file_minimap = $lib_minimap . '/dist/Control.MiniMap.min.js';
if (!file_exists($file_minimap)) {
$form['mini_map']['#description'] .= '<br/>' . $this->t('Error: <em>leaflet-minimap</em> library found, but %js_file is missing.', array('%js_file' => $file_minimap));
}
}
else {
$form['mini_map']['#description'] .= '<br/>' . $this->t('Requires this <a target="_js" href="@js_lib">JS library</a> to be downloaded to <em>/sites/all/libraries</em>. Change the directory name to <em>leaflet-minimap</em>.', array(
'@js_lib' => 'https://github.com/Norkart/Leaflet-Minimap'));
}*/
}