You are here

class StyledGoogleMapDefaultFormatter in Styled Google Map 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldFormatter/StyledGoogleMapDefaultFormatter.php \Drupal\styled_google_map\Plugin\Field\FieldFormatter\StyledGoogleMapDefaultFormatter

Plugin implementation of the 'styled_google_map_default' formatter.

Plugin annotation


@FieldFormatter(
  id = "styled_google_map_default",
  label = @Translation("Styled Google Map"),
  field_types = {
    "geofield"
  }
)

Hierarchy

Expanded class hierarchy of StyledGoogleMapDefaultFormatter

File

src/Plugin/Field/FieldFormatter/StyledGoogleMapDefaultFormatter.php, line 22

Namespace

Drupal\styled_google_map\Plugin\Field\FieldFormatter
View source
class StyledGoogleMapDefaultFormatter extends FormatterBase {

  /**
   * {@inheritdoc}
   */
  public static function defaultSettings() {
    return array(
      'width' => STYLED_GOOGLE_MAP_DEFAULT_WIDTH,
      'height' => STYLED_GOOGLE_MAP_DEFAULT_HEIGHT,
      'gestureHandling' => STYLED_GOOGLE_MAP_DEFAULT_GESTURE,
      'style' => array(
        'maptype' => STYLED_GOOGLE_MAP_DEFAULT_MAP_TYPE,
        'style' => STYLED_GOOGLE_MAP_DEFAULT_STYLE,
        'pin' => '',
      ),
      'map_center' => array(
        'center_coordinates' => NULL,
      ),
      'popup' => array(
        'choice' => NULL,
        'text' => NULL,
        'view_mode' => NULL,
        'label' => STYLED_GOOGLE_MAP_DEFAULT_LABEL,
        'shadow_style' => STYLED_GOOGLE_MAP_DEFAULT_SHADOW_STYLE,
        'padding' => STYLED_GOOGLE_MAP_DEFAULT_PADDING,
        'border_radius' => STYLED_GOOGLE_MAP_DEFAULT_BORDER_RADIUS,
        'border_width' => STYLED_GOOGLE_MAP_DEFAULT_BORDER_WIDTH,
        'border_color' => STYLED_GOOGLE_MAP_DEFAULT_BORDER_COLOR,
        'background_color' => STYLED_GOOGLE_MAP_DEFAULT_BACKGROUND_COLOR,
        'min_width' => STYLED_GOOGLE_MAP_DEFAULT_MIN_WIDTH,
        'max_width' => STYLED_GOOGLE_MAP_DEFAULT_MAX_WIDTH,
        'min_height' => STYLED_GOOGLE_MAP_DEFAULT_MIN_HEIGHT,
        'max_height' => STYLED_GOOGLE_MAP_DEFAULT_MAX_HEIGHT,
        'arrow_style' => STYLED_GOOGLE_MAP_DEFAULT_ARROW_STYLE,
        'arrow_size' => STYLED_GOOGLE_MAP_DEFAULT_ARROW_SIZE,
        'arrow_position' => STYLED_GOOGLE_MAP_DEFAULT_ARROW_POSITION,
        'disable_auto_pan' => STYLED_GOOGLE_MAP_DEFAULT_DISABLE_AUTO_PAN,
        'hide_close_button' => STYLED_GOOGLE_MAP_DEFAULT_HIDE_CLOSE_BUTTON,
        'disable_animation' => STYLED_GOOGLE_MAP_DEFAULT_DISABLE_ANIMATION,
        'classes' => array(
          'content_container' => STYLED_GOOGLE_MAP_DEFAULT_CONTENT_CONTAINER_CLASS,
          'background' => STYLED_GOOGLE_MAP_DEFAULT_BACKGROUND_CLASS,
          'arrow' => STYLED_GOOGLE_MAP_DEFAULT_ARROW_CLASS,
          'arrow_outer' => STYLED_GOOGLE_MAP_DEFAULT_ARROW_OUTER_CLASS,
          'arrow_inner' => STYLED_GOOGLE_MAP_DEFAULT_ARROW_INNER_CLASS,
        ),
      ),
      'zoom' => array(
        'default' => STYLED_GOOGLE_MAP_DEFAULT_ZOOM,
        'max' => STYLED_GOOGLE_MAP_DEFAULT_MAX_ZOOM,
        'min' => STYLED_GOOGLE_MAP_DEFAULT_MIN_ZOOM,
      ),
      'maptypecontrol' => STYLED_GOOGLE_MAP_DEFAULT_MAP_TYPE_CONTROL,
      'scalecontrol' => STYLED_GOOGLE_MAP_DEFAULT_SCALE_CONTROL,
      'rotatecontrol' => STYLED_GOOGLE_MAP_DEFAULT_ROTATE_CONTROL,
      'draggable' => STYLED_GOOGLE_MAP_DEFAULT_DRAGGABLE,
      'mobile_draggable' => STYLED_GOOGLE_MAP_DEFAULT_MOBILE_DRAGGABLE,
      'zoomcontrol' => STYLED_GOOGLE_MAP_DEFAULT_ZOOM_CONTROL,
      'streetviewcontrol' => STYLED_GOOGLE_MAP_DEFAULT_STREET_VIEW_CONTROL,
    );
  }

  /**
   * {@inheritdoc}
   */
  public function settingsForm(array $form, FormStateInterface $form_state) {
    $elements = parent::settingsForm($form, $form_state);
    $default_settings = StyledGoogleMapDefaultFormatter::defaultSettings();

    // Set all available setting fields for the Styled Google Map.
    $elements['width'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Width size'),
      '#default_value' => $this
        ->getSetting('width'),
      '#description' => $this
        ->t('Map width written in pixels or percentage'),
      '#required' => TRUE,
    );
    $elements['height'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Height size'),
      '#default_value' => $this
        ->getSetting('height'),
      '#description' => $this
        ->t('Map height written in pixels or percentage'),
      '#required' => TRUE,
    );
    $elements['gestureHandling'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Gesture handling'),
      '#description' => $this
        ->t('This setting controls how the API handles gestures on the map. See more <a href="@href">here</a>', [
        '@href' => 'https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions.gestureHandling',
      ]),
      '#options' => [
        'cooperative' => $this
          ->t('Scroll events with a ctrl key or ⌘ key pressed zoom the map.'),
        'greedy' => $this
          ->t('All touch gestures and scroll events pan or zoom the map.'),
        'none' => $this
          ->t('The map cannot be panned or zoomed by user gestures.'),
        'auto' => $this
          ->t('(default) Gesture handling is either cooperative or greedy'),
      ],
      '#default_value' => $this
        ->getSetting('gestureHandling'),
    ];
    $elements['style'] = array(
      '#type' => 'details',
      '#title' => $this
        ->t('Map style'),
    );
    $style_settings = $this
      ->getSetting('style');
    $elements['style']['maptype'] = array(
      '#type' => 'select',
      '#options' => array(
        'ROADMAP' => $this
          ->t('ROADMAP'),
        'SATELLITE' => $this
          ->t('SATELLITE'),
        'HYBRID' => $this
          ->t('HYBRID'),
        'TERRAIN' => $this
          ->t('TERRAIN'),
      ),
      '#title' => $this
        ->t('Map type'),
      '#default_value' => empty($style_settings['maptype']) ? $default_settings['style']['maptype'] : $style_settings['maptype'],
      '#required' => TRUE,
    );
    $elements['style']['style'] = array(
      '#type' => 'textarea',
      '#title' => $this
        ->t('JSON Style'),
      '#default_value' => empty($style_settings['style']) ? $default_settings['style']['style'] : $style_settings['style'],
      '#description' => $this
        ->t('Check out !url for custom styles. Also check out this !project to style and edit Google Map JSON styles.', array(
        '!url' => \Drupal::service('link_generator')
          ->generate($this
          ->t('Snazzy maps'), Url::fromUri('http://snazzymaps.com/')),
        '!project' => \Drupal::service('link_generator')
          ->generate($this
          ->t('Github page'), Url::fromUri('http://instrument.github.io/styled-maps-wizard/')),
      )),
    );
    $elements['style']['pin'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('URL to the marker'),
      '#default_value' => empty($style_settings['pin']) ? $default_settings['style']['pin'] : $style_settings['pin'],
      '#description' => $this
        ->t('URL to the marker image. You can use a !wrapper for the url. Ex. !example (not working until !fixed)', array(
        '!wrapper' => \Drupal::service('link_generator')
          ->generate($this
          ->t('Stream wrapper'), Url::fromUri('https://drupal.org/project/system_stream_wrapper')),
        '!example' => STYLED_GOOGLE_MAP_DEFAULT_PIN,
        '!fixed' => \Drupal::service('link_generator')
          ->generate('https://www.drupal.org/node/1308152', Url::fromUri('https://www.drupal.org/node/1308152')),
      )),
    );
    $map_center_settings = $this
      ->getSetting('map_center');
    $elements['map_center'] = array(
      '#type' => 'details',
      '#title' => $this
        ->t('Centering map'),
    );

    // Retrieve all field names from the current entity bundle.
    // Retrieve all field names from the current entity bundle.
    $field_options = array();
    $center_options = array(
      '' => $this
        ->t('Center automatically'),
    );
    $fields = $form['#fields'];
    foreach ($fields as $field) {
      $config = FieldConfig::loadByName($form['#entity_type'], $form['#bundle'], $field);
      if (!$config) {
        continue;
      }
      $type = $config
        ->get('field_type');
      $name = $config
        ->get('field_name');
      $field_options[$field] = $config
        ->getLabel();
      if ($type == 'geofield' && $this->fieldDefinition
        ->get('field_name') != $name) {
        $center_options[$field] = $config
          ->getLabel();
      }
    }
    $elements['map_center']['center_coordinates'] = array(
      '#type' => 'select',
      '#options' => $center_options,
      '#default_value' => empty($map_center_settings['center_coordinates']) ? $default_settings['map_center']['center_coordinates'] : $map_center_settings['center_coordinates'],
      '#description' => $this
        ->t('To have map centered on other point than location you need to have another GeoField in your content type structure'),
    );
    $elements['popup'] = array(
      '#type' => 'details',
      '#title' => $this
        ->t('Marker popup'),
    );
    $popup_settings = $this
      ->getSetting('popup');
    $elements['popup']['choice'] = array(
      '#type' => 'select',
      '#options' => array(
        0 => $this
          ->t('None'),
        1 => $this
          ->t('Field'),
        2 => $this
          ->t('View mode'),
      ),
      '#default_value' => empty($popup_settings['choice']) ? $default_settings['popup']['choice'] : $popup_settings['choice'],
      '#id' => 'edit-popup-choice-field',
    );

    // Retrieve view mode settings from the current entity bundle.
    $view_modes = \Drupal::service('entity_display.repository')
      ->getViewModeOptions($form['#entity_type']);
    $elements['popup']['view_mode'] = array(
      '#type' => 'select',
      '#options' => $view_modes,
      '#default_value' => empty($popup_settings['view_mode']) ? $default_settings['popup']['view_mode'] : $popup_settings['view_mode'],
      '#states' => array(
        'visible' => array(
          ':input[id="edit-popup-choice-field"]' => array(
            'value' => 2,
          ),
        ),
      ),
    );
    $elements['popup']['text'] = array(
      '#type' => 'select',
      '#options' => $field_options,
      '#default_value' => empty($popup_settings['text']) ? $default_settings['popup']['text'] : $popup_settings['text'],
      '#states' => array(
        'visible' => array(
          ':input[id="edit-popup-choice-field"]' => array(
            'value' => 1,
          ),
        ),
      ),
    );
    $elements['popup']['label'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Show field label'),
      '#default_value' => empty($popup_settings['label']) ? $default_settings['popup']['label'] : $popup_settings['label'],
      '#states' => array(
        'visible' => array(
          ':input[id="edit-popup-choice-field"]' => array(
            'value' => 1,
          ),
        ),
      ),
    );
    $elements['popup']['shadow_style'] = array(
      '#type' => 'select',
      '#title' => $this
        ->t('Shadow style'),
      '#options' => array(
        0,
        1,
        2,
      ),
      '#description' => $this
        ->t('1: shadow behind, 2: shadow below, 0: no shadow'),
      '#default_value' => empty($popup_settings['shadow_style']) ? $default_settings['popup']['shadow_style'] : $popup_settings['shadow_style'],
    );
    $elements['popup']['padding'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Padding'),
      '#field_suffix' => 'px',
      '#default_value' => empty($popup_settings['padding']) ? $default_settings['popup']['padding'] : $popup_settings['padding'],
    );
    $elements['popup']['border_radius'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Border radius'),
      '#field_suffix' => 'px',
      '#default_value' => empty($popup_settings['border_radius']) ? $default_settings['popup']['border_radius'] : $popup_settings['border_radius'],
    );
    $elements['popup']['border_width'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Border width'),
      '#field_suffix' => 'px',
      '#default_value' => empty($popup_settings['border_width']) ? $default_settings['popup']['border_width'] : $popup_settings['border_width'],
    );
    $elements['popup']['border_color'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Border color'),
      '#field_suffix' => '#hex',
      '#default_value' => empty($popup_settings['border_color']) ? $default_settings['popup']['border_color'] : $popup_settings['border_color'],
    );
    $elements['popup']['background_color'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Background color'),
      '#field_suffix' => '#hex',
      '#default_value' => empty($popup_settings['background_color']) ? $default_settings['popup']['background_color'] : $popup_settings['background_color'],
    );
    $elements['popup']['min_width'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Min width'),
      '#field_suffix' => 'px (or auto)',
      '#default_value' => empty($popup_settings['min_width']) ? $default_settings['popup']['min_width'] : $popup_settings['min_width'],
    );
    $elements['popup']['max_width'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Max width'),
      '#field_suffix' => 'px (or auto)',
      '#default_value' => empty($popup_settings['max_width']) ? $default_settings['popup']['max_width'] : $popup_settings['max_width'],
    );
    $elements['popup']['min_height'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Min height'),
      '#field_suffix' => 'px (or auto)',
      '#default_value' => empty($popup_settings['min_height']) ? $default_settings['popup']['min_height'] : $popup_settings['min_height'],
    );
    $elements['popup']['max_height'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Max height'),
      '#field_suffix' => 'px (or auto)',
      '#default_value' => empty($popup_settings['max_height']) ? $default_settings['popup']['max_height'] : $popup_settings['max_height'],
    );
    $elements['popup']['arrow_style'] = array(
      '#type' => 'select',
      '#title' => $this
        ->t('Arrow style'),
      '#options' => array(
        0,
        1,
        2,
      ),
      '#description' => $this
        ->t('1: left side visible, 2: right side visible, 0: both sides visible'),
      '#default_value' => empty($popup_settings['arrow_style']) ? $default_settings['popup']['arrow_style'] : $popup_settings['arrow_style'],
    );
    $elements['popup']['arrow_size'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Arrow size'),
      '#field_suffix' => 'px',
      '#default_value' => empty($popup_settings['arrow_size']) ? $default_settings['popup']['arrow_size'] : $popup_settings['arrow_size'],
    );
    $elements['popup']['arrow_position'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Arrow position'),
      '#field_suffix' => 'px',
      '#default_value' => empty($popup_settings['arrow_position']) ? $default_settings['popup']['arrow_position'] : $popup_settings['arrow_position'],
    );
    $elements['popup']['disable_auto_pan'] = array(
      '#type' => 'select',
      '#title' => $this
        ->t('Auto pan'),
      '#options' => array(
        1 => $this
          ->t('Yes'),
        0 => $this
          ->t('No'),
      ),
      '#description' => $this
        ->t('Automatically center the pin on click'),
      '#default_value' => empty($popup_settings['disable_auto_pan']) ? $default_settings['popup']['disable_auto_pan'] : $popup_settings['disable_auto_pan'],
    );
    $elements['popup']['hide_close_button'] = array(
      '#type' => 'select',
      '#title' => $this
        ->t('Hide close button'),
      '#options' => array(
        1 => $this
          ->t('Yes'),
        0 => $this
          ->t('No'),
      ),
      '#description' => $this
        ->t('Hide the popup close button'),
      '#default_value' => empty($popup_settings['hide_close_button']) ? $default_settings['popup']['hide_close_button'] : $popup_settings['hide_close_button'],
    );
    $elements['popup']['disable_animation'] = array(
      '#type' => 'select',
      '#title' => $this
        ->t('Disable animation'),
      '#options' => array(
        1 => $this
          ->t('Yes'),
        0 => $this
          ->t('No'),
      ),
      '#description' => $this
        ->t('Disables the popup animation'),
      '#default_value' => empty($popup_settings['disable_animation']) ? $default_settings['popup']['disable_animation'] : $popup_settings['disable_animation'],
    );
    $popup_classes_settings = !empty($popup_settings['classes']) ? $popup_settings['classes'] : $default_settings['popup']['classes'];
    $elements['popup']['classes']['content_container'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Wrapper class'),
      '#default_value' => empty($popup_classes_settings['content_container']) ? $default_settings['popup']['classes']['content_container'] : $popup_classes_settings['content_container'],
    );
    $elements['popup']['classes']['background'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Background class'),
      '#default_value' => empty($popup_classes_settings['background']) ? $default_settings['popup']['classes']['background'] : $popup_classes_settings['background'],
    );
    $elements['popup']['classes']['arrow'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Arrow class'),
      '#default_value' => empty($popup_classes_settings['arrow']) ? $default_settings['popup']['classes']['arrow'] : $popup_classes_settings['arrow'],
    );
    $elements['popup']['classes']['arrow_outer'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Arrow outer class'),
      '#default_value' => empty($popup_classes_settings['arrow_outer']) ? $default_settings['popup']['classes']['arrow_outer'] : $popup_classes_settings['arrow_outer'],
    );
    $elements['popup']['classes']['arrow_inner'] = array(
      '#type' => 'textfield',
      '#title' => $this
        ->t('Arrow inner class'),
      '#default_value' => empty($popup_classes_settings['arrow_inner']) ? $default_settings['popup']['classes']['arrow_inner'] : $popup_classes_settings['arrow_inner'],
    );
    $elements['zoom'] = array(
      '#type' => 'details',
      '#title' => $this
        ->t('Zoom'),
    );
    $zoom_settings = $this
      ->getSetting('zoom');
    $elements['zoom']['default'] = array(
      '#type' => 'select',
      '#options' => range(1, 23),
      '#title' => $this
        ->t('Default zoom level'),
      '#default_value' => empty($zoom_settings['default']) ? $default_settings['zoom']['default'] : $zoom_settings['default'],
      '#description' => $this
        ->t('Should be between the Min and Max zoom level.'),
      '#required' => TRUE,
    );
    $elements['zoom']['max'] = array(
      '#type' => 'select',
      '#options' => range(1, 23),
      '#title' => $this
        ->t('Max zoom level'),
      '#default_value' => empty($zoom_settings['max']) ? $default_settings['zoom']['max'] : $zoom_settings['max'],
      '#description' => $this
        ->t('Should be greater then the Min zoom level.'),
      '#required' => TRUE,
    );
    $elements['zoom']['min'] = array(
      '#type' => 'select',
      '#options' => range(1, 23),
      '#title' => $this
        ->t('Min zoom level'),
      '#default_value' => empty($zoom_settings['min']) ? $default_settings['zoom']['min'] : $zoom_settings['min'],
      '#description' => $this
        ->t('Should be smaller then the Max zoom level.'),
      '#required' => TRUE,
    );
    $elements['maptypecontrol'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable Map Type control'),
      '#default_value' => $this
        ->getSetting('maptypecontrol'),
    );
    $elements['scalecontrol'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable scale control'),
      '#default_value' => $this
        ->getSetting('scalecontrol'),
    );
    $elements['rotatecontrol'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable rotate control'),
      '#default_value' => $this
        ->getSetting('rotatecontrol'),
    );
    $elements['draggable'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable dragging'),
      '#default_value' => $this
        ->getSetting('draggable'),
    );
    $elements['mobile_draggable'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable mobile dragging'),
      '#description' => $this
        ->t('Sometimes when the map covers big part of touch device screen draggable feature can cause inability to scroll the page'),
      '#default_value' => $this
        ->getSetting('mobile_draggable'),
    );
    $elements['streetviewcontrol'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable street view control'),
      '#default_value' => $this
        ->getSetting('streetviewcontrol'),
    );
    $elements['zoomcontrol'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Enable zoom control'),
      '#default_value' => $this
        ->getSetting('zoomcontrol'),
    );
    return $elements;
  }

  /**
   * {@inheritdoc}
   */
  public function settingsSummary() {
    $summary = array();
    $summary[] = $this
      ->t('Width: <b>%width</b><br />Height: <b>%height</b>', array(
      '%width' => $this
        ->getSetting('width'),
      '%height' => $this
        ->getSetting('height'),
    ));
    $style_settings = $this
      ->getSetting('style');
    if ($style_settings['style']) {
      $summary[] = $this
        ->t('<br />Map style: <b>Custom</b>');
    }
    if ($style_settings['pin']) {
      $summary[] = $this
        ->t('<br />Pin style: <b>%pin</b>', array(
        '%pin' => $style_settings['pin'],
      ));
    }
    $summary[] = $this
      ->t('<br />Map type: <b>%maptype</b>', array(
      '%maptype' => $style_settings['maptype'],
    ));
    if ($style_settings['pin']) {
      $summary[] = $this
        ->t('<br />Pin location: <b>%pin</b>', array(
        '%pin' => $style_settings['pin'],
      ));
    }
    $popup_settings = $this
      ->getSetting('popup');
    if ($popup_settings['choice'] == 1) {
      $summary[] = $this
        ->t('<br />Popup shows field <b>%field</b>', array(
        '%field' => $popup_settings['text'],
      ));
      $readable = array(
        FALSE => $this
          ->t('without'),
        TRUE => $this
          ->t('with'),
      );
      $summary[] = $this
        ->t('<b>%label</b> label', array(
        '%label' => $readable[$popup_settings['label']],
      ));
    }
    if ($popup_settings['choice'] == 2) {
      $summary[] = $this
        ->t('<br />Popup shows view mode <b>%viewmode</b>', array(
        '%viewmode' => $popup_settings['view_mode'],
      ));
    }
    $zoom_settings = $this
      ->getSetting('zoom');
    $summary[] = $this
      ->t('<br />Default zoom: <b>%zoom</b>', array(
      '%zoom' => $zoom_settings['default'],
    ));
    $summary[] = $this
      ->t('<br />Maximum zoom: <b>%maxzoom</b>', array(
      '%maxzoom' => $zoom_settings['max'],
    ));
    $summary[] = $this
      ->t('<br />Minimum zoom: <b>%minzoom</b>', array(
      '%minzoom' => $zoom_settings['min'],
    ));
    $gesture_handling = $this
      ->getSetting('gestureHandling');
    $summary[] = $this
      ->t('<br />Gesture handling:<b>%mode</b>', [
      '%mode' => $gesture_handling,
    ]);
    return $summary;
  }

  /**
   * {@inheritdoc}
   */
  public function viewElements(FieldItemListInterface $items, $langcode) {
    $elements = array();
    foreach ($items as $delta => $item) {
      $elements[$delta] = array(
        '#markup' => theme_styled_google_map(array(
          'location' => $item,
          'settings' => $this
            ->getSettings(),
        )),
      );
    }
    return $elements;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
FormatterBase::$fieldDefinition protected property The field definition.
FormatterBase::$label protected property The label display setting.
FormatterBase::$settings protected property The formatter settings. Overrides PluginSettingsBase::$settings
FormatterBase::$viewMode protected property The view mode.
FormatterBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create 11
FormatterBase::getFieldSetting protected function Returns the value of a field setting.
FormatterBase::getFieldSettings protected function Returns the array of field settings.
FormatterBase::isApplicable public static function Returns if the formatter can be used for the provided field. Overrides FormatterInterface::isApplicable 14
FormatterBase::prepareView public function Allows formatters to load information for field values being displayed. Overrides FormatterInterface::prepareView 2
FormatterBase::view public function Builds a renderable array for a fully themed field. Overrides FormatterInterface::view 1
FormatterBase::__construct public function Constructs a FormatterBase object. Overrides PluginBase::__construct 11
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
PluginSettingsBase::$defaultSettingsMerged protected property Whether default settings have been merged into the current $settings.
PluginSettingsBase::$thirdPartySettings protected property The plugin settings injected by third party modules.
PluginSettingsBase::calculateDependencies public function Calculates dependencies for the configured plugin. Overrides DependentPluginInterface::calculateDependencies 6
PluginSettingsBase::getSetting public function Returns the value of a setting, or its default value if absent. Overrides PluginSettingsInterface::getSetting
PluginSettingsBase::getSettings public function Returns the array of settings, including defaults for missing settings. Overrides PluginSettingsInterface::getSettings
PluginSettingsBase::getThirdPartyProviders public function Gets the list of third parties that store information. Overrides ThirdPartySettingsInterface::getThirdPartyProviders
PluginSettingsBase::getThirdPartySetting public function Gets the value of a third-party setting. Overrides ThirdPartySettingsInterface::getThirdPartySetting
PluginSettingsBase::getThirdPartySettings public function Gets all third-party settings of a given module. Overrides ThirdPartySettingsInterface::getThirdPartySettings
PluginSettingsBase::mergeDefaults protected function Merges default settings values into $settings.
PluginSettingsBase::onDependencyRemoval public function Informs the plugin that some configuration it depends on will be deleted. Overrides PluginSettingsInterface::onDependencyRemoval 3
PluginSettingsBase::setSetting public function Sets the value of a setting for the plugin. Overrides PluginSettingsInterface::setSetting
PluginSettingsBase::setSettings public function Sets the settings for the plugin. Overrides PluginSettingsInterface::setSettings
PluginSettingsBase::setThirdPartySetting public function Sets the value of a third-party setting. Overrides ThirdPartySettingsInterface::setThirdPartySetting
PluginSettingsBase::unsetThirdPartySetting public function Unsets a third-party setting. Overrides ThirdPartySettingsInterface::unsetThirdPartySetting
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
StyledGoogleMapDefaultFormatter::defaultSettings public static function Defines the default settings for this plugin. Overrides PluginSettingsBase::defaultSettings
StyledGoogleMapDefaultFormatter::settingsForm public function Returns a form to configure settings for the formatter. Overrides FormatterBase::settingsForm
StyledGoogleMapDefaultFormatter::settingsSummary public function Returns a short summary for the current formatter settings. Overrides FormatterBase::settingsSummary
StyledGoogleMapDefaultFormatter::viewElements public function Builds a renderable array for a field value. Overrides FormatterInterface::viewElements