diff --git a/config/schema/geolocation.schema.yml b/config/schema/geolocation.schema.yml index d07248f..087c4cf 100644 --- a/config/schema/geolocation.schema.yml +++ b/config/schema/geolocation.schema.yml @@ -8,7 +8,7 @@ views.style.maps_common: title_field: type: string label: 'Title Field' - centre: + center: type: sequence label: 'Centre Option' sequence: diff --git a/geolocation.module b/geolocation.module index 6db984c..45f8985 100644 --- a/geolocation.module +++ b/geolocation.module @@ -43,7 +43,7 @@ function geolocation_theme() { ], 'geolocation_common_map_display' => [ 'variables' => [ - 'centre' => NULL, + 'center' => NULL, 'zoom' => NULL, 'fitbounds' => NULL, 'locations' => NULL, diff --git a/js/geolocation-common-map.js b/js/geolocation-common-map.js index 475e9fd..e00ba11 100644 --- a/js/geolocation-common-map.js +++ b/js/geolocation-common-map.js @@ -38,8 +38,8 @@ var container = map.children('.geolocation-common-map-container'); container.show(); - if (map.data('centre-lat') && map.data('centre-lng')) { - center = new google.maps.LatLng(map.data('centre-lat'), map.data('centre-lng')); + if (map.data('center-lat') && map.data('center-lng')) { + center = new google.maps.LatLng(map.data('center-lat'), map.data('center-lng')); } else { center = new google.maps.LatLng(0, 0); diff --git a/src/Plugin/views/style/CommonMap.php b/src/Plugin/views/style/CommonMap.php index a25434a..08aa6a9 100644 --- a/src/Plugin/views/style/CommonMap.php +++ b/src/Plugin/views/style/CommonMap.php @@ -108,14 +108,14 @@ class CommonMap extends StylePluginBase { } } - $centre = NULL; + $center = NULL; $zoom = NULL; $fitbounds = FALSE; - if (!is_array($this->options['centre'])) { + if (!is_array($this->options['center'])) { return $build; } - foreach ($this->options['centre'] as $id => $option) { + foreach ($this->options['center'] as $id => $option) { // Ignore if not enabled. if (empty($option['enable'])) { continue; @@ -127,7 +127,7 @@ class CommonMap extends StylePluginBase { } // Ignore if center is already set. - if (!empty($centre['lat']) && !empty($centre['lng'])) { + if (!empty($center['lat']) && !empty($center['lng'])) { break; } @@ -135,7 +135,7 @@ class CommonMap extends StylePluginBase { switch ($id) { case 'fixed_value': - $centre = [ + $center = [ 'lat' => (float)$option['settings']['latitude'], 'lng' => (float)$option['settings']['longitude'], ]; @@ -147,7 +147,7 @@ class CommonMap extends StylePluginBase { /** @var \Drupal\geolocation\Plugin\views\filter\ProximityFilter $handler */ $handler = $this->displayHandler->getHandler('filter', $filter_id); if ($handler->value['lat'] && $handler->value['lng']) { - $centre = [ + $center = [ 'lat' => (float) $handler->value['lat'], 'lng' => (float) $handler->value['lng'], ]; @@ -156,7 +156,7 @@ class CommonMap extends StylePluginBase { case 'first_row': if (!empty($build['#locations'][0]['#position'])) { - $centre = $build['#locations'][0]['#position']; + $center = $build['#locations'][0]['#position']; } $zoom = (int)$option['settings']['zoom']; break; @@ -171,8 +171,8 @@ class CommonMap extends StylePluginBase { } } - if (!empty($centre)) { - $build['#centre'] = $centre ?: ['lat' => 0, 'lng' => 0]; + if (!empty($center)) { + $build['#center'] = $center ?: ['lat' => 0, 'lng' => 0]; $build['#zoom'] = $zoom ?: 12; } $build['#fitbounds'] = $fitbounds; @@ -188,7 +188,7 @@ class CommonMap extends StylePluginBase { $options['geolocation_field'] = ['default' => '']; $options['title_field'] = ['default' => '']; - $options['centre'] = ['default' => '']; + $options['center'] = ['default' => '']; return $options; } @@ -243,7 +243,7 @@ class CommonMap extends StylePluginBase { $options = [ 'fit_bounds' => $this->t('Automatically fit map bounds to results. Disregards any set center or zoom.'), - 'first_row' => $this->t('Use first row as centre.'), + 'first_row' => $this->t('Use first row as center.'), 'fixed_value' => $this->t('Provide fixed latitude and longitude.'), ]; @@ -256,58 +256,58 @@ class CommonMap extends StylePluginBase { $options['proximity_filter_' . $filter_name] = $proximity_filter_handler->adminLabel(); } - $form['centre'] = [ + $form['center'] = [ '#type' => 'table', '#prefix' => t('Please note: Each option will, if it can be applied, supersede any following option.'), '#header' => [ t('Enable'), t('Option'), t('settings'), array('data' => t('Settings'), 'colspan' => '1')], - '#attributes' => ['id' => 'geolocation-centre-options'], + '#attributes' => ['id' => 'geolocation-center-options'], '#tabledrag' => [ [ 'action' => 'order', 'relationship' => 'sibling', - 'group' => 'geolocation-centre-option-weight', + 'group' => 'geolocation-center-option-weight', ], ], ]; foreach ($options as $id => $label) { - $weight = $this->options['centre'][$id]['weight'] ?: 0; - $form['centre'][$id]['#weight'] = $weight; + $weight = $this->options['center'][$id]['weight'] ?: 0; + $form['center'][$id]['#weight'] = $weight; - $form['centre'][$id]['enable'] = [ + $form['center'][$id]['enable'] = [ '#type' => 'checkbox', - '#default_value' => isset($this->options['centre'][$id]['enable']) ? $this->options['centre'][$id]['enable'] : TRUE, + '#default_value' => isset($this->options['center'][$id]['enable']) ? $this->options['center'][$id]['enable'] : TRUE, ]; - $form['centre'][$id]['option'] = [ + $form['center'][$id]['option'] = [ '#markup' => $label, ]; // Optionally, to add tableDrag support: - $form['centre'][$id]['#attributes']['class'][] = 'draggable'; - $form['centre'][$id]['weight'] = [ + $form['center'][$id]['#attributes']['class'][] = 'draggable'; + $form['center'][$id]['weight'] = [ '#type' => 'weight', '#title' => t('Weight for @option', ['@option' => $label]), '#title_display' => 'invisible', '#size' => 4, '#default_value' => $weight, - '#attributes' => ['class' => ['geolocation-centre-option-weight']], + '#attributes' => ['class' => ['geolocation-center-option-weight']], ]; } - $form['centre']['fixed_value']['settings'] = [ + $form['center']['fixed_value']['settings'] = [ '#type' => 'container', 'latitude' => [ '#type' => 'textfield', '#title' => t('Latitude'), - '#default_value' => $this->options['centre']['fixed_value']['settings']['latitude'], + '#default_value' => $this->options['center']['fixed_value']['settings']['latitude'], '#size' => 60, '#maxlength' => 128, ], 'longitude' => [ '#type' => 'textfield', '#title' => t('Longitude'), - '#default_value' => $this->options['centre']['fixed_value']['settings']['longitude'], + '#default_value' => $this->options['center']['fixed_value']['settings']['longitude'], '#size' => 60, '#maxlength' => 128, ], @@ -316,31 +316,31 @@ class CommonMap extends StylePluginBase { '#title' => t('Zoom level'), '#description' => t('1 = world, 20 = maximum zoom'), '#options' => range(1, 20), - '#default_value' => empty($this->options['centre']['fixed_value']['settings']['zoom']) ? 12 : $this->options['centre']['fixed_value']['settings']['zoom'], + '#default_value' => empty($this->options['center']['fixed_value']['settings']['zoom']) ? 12 : $this->options['center']['fixed_value']['settings']['zoom'], ], '#states' => [ 'visible' => [ - ':input[name="style_options[centre][fixed_value][enable]"]' => ['checked' => TRUE], + ':input[name="style_options[center][fixed_value][enable]"]' => ['checked' => TRUE], ], ], ]; - $form['centre']['first_row']['settings'] = [ + $form['center']['first_row']['settings'] = [ '#type' => 'container', 'zoom' => [ '#type' => 'select', '#title' => t('Zoom level'), '#description' => t('1 = world, 20 = maximum zoom'), '#options' => range(1, 20), - '#default_value' => empty($this->options['centre']['first_row']['settings']['zoom']) ? 12 : $this->options['centre']['first_row']['settings']['zoom'], + '#default_value' => empty($this->options['center']['first_row']['settings']['zoom']) ? 12 : $this->options['center']['first_row']['settings']['zoom'], ], '#states' => [ 'visible' => [ - ':input[name="style_options[centre][first_row][enable]"]' => ['checked' => TRUE], + ':input[name="style_options[center][first_row][enable]"]' => ['checked' => TRUE], ], ], ]; - uasort($form['centre'], 'Drupal\Component\Utility\SortArray::sortByWeightProperty'); + uasort($form['center'], 'Drupal\Component\Utility\SortArray::sortByWeightProperty'); } } diff --git a/templates/geolocation-common-map-display.html.twig b/templates/geolocation-common-map-display.html.twig index a177a70..04f7523 100644 --- a/templates/geolocation-common-map-display.html.twig +++ b/templates/geolocation-common-map-display.html.twig @@ -1,4 +1,4 @@ -