You are here

public function styled_google_map_style_plugin::options_form in Styled Google Map 7.2

Same name and namespace in other branches
  1. 7 styled_google_views/styled_google_map_style_plugin.inc \styled_google_map_style_plugin::options_form()

Modifies the options form inherited by this plugin.

@codingStandardsIgnoreStart

Parameters

array $form: The form being generated.

array $form_state: The state that the form has been posted in.

Overrides views_plugin_style::options_form

File

styled_google_views/styled_google_map_style_plugin.inc, line 86

Class

styled_google_map_style_plugin
Class for plugin.

Code

public function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);

  // @codingStandardsIgnoreEnd
  $handlers = $this->display->handler
    ->get_handlers('field');
  $pin_source_options = array();
  foreach ($handlers as $handle) {

    // Get all location sources.
    if (!empty($handle->field_info['type']) && $handle->field_info['type'] == 'geofield') {
      $data_source_options[$handle->options['id']] = !empty($handle->options['label']) ? $handle->options['label'] : $handle->options['id'];
    }

    // Get all pin sources.
    if (!empty($handle->field_info['type']) && $handle->field_info['type'] == 'image') {
      $pin_source_options[$handle->options['id']] = !empty($handle->options['label']) ? $handle->options['label'] : $handle->options['id'];
    }

    // Get all popup sources.
    $source_options[$handle->options['id']] = !empty($handle->options['label']) ? $handle->options['label'] : $handle->options['id'];
  }
  $source_options = array_diff($source_options, $pin_source_options, $data_source_options);
  $form['data_source'] = array(
    '#type' => 'select',
    '#title' => t('Which field contains geodata?'),
    '#description' => t('Needs to be a geofield.'),
    '#options' => $data_source_options,
    '#default_value' => $this->options['data_source'] ? $this->options['data_source'] : NULL,
  );
  $form['pin_source'] = array(
    '#type' => 'select',
    '#title' => t('Which field contains the pin image?'),
    '#description' => t('Needs to be an image field.'),
    '#options' => $pin_source_options,
    '#default_value' => $this->options['pin_source'] ? $this->options['pin_source'] : NULL,
  );
  $form['popup_source'] = array(
    '#type' => 'select',
    '#title' => t('Which field contains the popup text?'),
    '#description' => t('Can be a field or rendered entity field.'),
    '#options' => $source_options,
    '#default_value' => $this->options['popup_source'] ? $this->options['popup_source'] : NULL,
  );
  $form['category_source'] = array(
    '#type' => 'select',
    '#title' => t('Which field contains the category?'),
    '#description' => t('This will be used to have a class wrapper around the bubble to allow different styling per category.'),
    '#options' => $source_options,
    '#default_value' => $this->options['category_source'] ? $this->options['category_source'] : NULL,
  );
  $form['styled_google_map_view_height'] = array(
    '#type' => 'textfield',
    '#title' => t('Height'),
    '#size' => '30',
    '#description' => t('This field determines the height of the styled Google map'),
    '#default_value' => $this->options['styled_google_map_view_height'],
  );
  $form['styled_google_map_view_default_pin'] = array(
    '#type' => 'textfield',
    '#title' => t('Default pin image'),
    '#description' => t('URL to the pin image. You can use a !wrapper for the url. Leave empty for using the default Google pin.', array(
      '!wrapper' => l(t('Stream wrapper'), 'https://drupal.org/project/system_stream_wrapper', array(
        'attributes' => array(
          'target' => '_blank',
        ),
      )),
    )),
    '#default_value' => $this->options['styled_google_map_view_default_pin'],
  );
  $form['styled_google_map_view_width'] = array(
    '#type' => 'textfield',
    '#title' => t('Width'),
    '#size' => '30',
    '#description' => t('This field determines how width the styled Google map'),
    '#default_value' => $this->options['styled_google_map_view_width'],
  );
  $form['styled_google_map_view_style'] = array(
    '#type' => 'textarea',
    '#title' => t('Style'),
    '#description' => t('The style of the map'),
    '#default_value' => $this->options['styled_google_map_view_style'],
  );
  $form['styled_google_map_view_cluster_pin'] = array(
    '#type' => 'textfield',
    '#title' => t('Cluster pin image'),
    '#description' => t('URL to the cluster image. You can use a !wrapper for the url. Leave empty for no clustering.', array(
      '!wrapper' => l(t('Stream wrapper'), 'https://drupal.org/project/system_stream_wrapper', array(
        'attributes' => array(
          'target' => '_blank',
        ),
      )),
    )),
    '#default_value' => $this->options['styled_google_map_view_cluster_pin'],
  );
  $form['styled_google_map_view_active_pin'] = array(
    '#type' => 'textfield',
    '#title' => t('Active pin image'),
    '#description' => t('URL to the active pin image. You can use a !wrapper for the url. Leave empty for using the default Google pin.', array(
      '!wrapper' => l(t('Stream wrapper'), 'https://drupal.org/project/system_stream_wrapper', array(
        'attributes' => array(
          'target' => '_blank',
        ),
      )),
    )),
    '#default_value' => $this->options['styled_google_map_view_active_pin'],
  );
  $form['styled_google_map_view_maptype'] = array(
    '#type' => 'select',
    '#options' => array(
      'ROADMAP' => t('ROADMAP'),
      'SATELLITE' => t('SATELLITE'),
      'HYBRID' => t('HYBRID'),
      'TERRAIN' => t('TERRAIN'),
    ),
    '#title' => t('Map type'),
    '#default_value' => $this->options['styled_google_map_view_maptype'],
    '#required' => TRUE,
  );
  $form['styled_google_map_view_zoom_default'] = array(
    '#type' => 'select',
    '#options' => range(1, 23),
    '#title' => t('Default zoom level'),
    '#default_value' => $this->options['styled_google_map_view_zoom_default'],
    '#description' => t('Should be between the Min and Max zoom level.
        This will generally not working as fitbounds will try to fit all pins on the map.'),
    '#required' => TRUE,
  );
  $form['styled_google_map_view_zoom_max'] = array(
    '#type' => 'select',
    '#options' => range(1, 23),
    '#title' => t('Max zoom level'),
    '#default_value' => $this->options['styled_google_map_view_zoom_max'],
    '#description' => t('Should be greater then the Min zoom level.'),
    '#required' => TRUE,
  );
  $form['styled_google_map_view_zoom_min'] = array(
    '#type' => 'select',
    '#options' => range(1, 23),
    '#title' => t('Min zoom level'),
    '#default_value' => $this->options['styled_google_map_view_zoom_min'],
    '#description' => t('Should be smaller then the Max zoom level.'),
    '#required' => TRUE,
  );
  $form['styled_google_map_view_maptypecontrol'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable Map Type control'),
    '#default_value' => $this->options['styled_google_map_view_maptypecontrol'],
  );
  $form['styled_google_map_view_scalecontrol'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable scale control'),
    '#default_value' => $this->options['styled_google_map_view_scalecontrol'],
  );
  $form['styled_google_map_view_rotatecontrol'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable rotate control'),
    '#default_value' => $this->options['styled_google_map_view_rotatecontrol'],
  );
  $form['styled_google_map_view_draggable'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable dragging'),
    '#default_value' => $this->options['styled_google_map_view_draggable'],
  );
  $form['styled_google_map_view_mobile_draggable'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable mobile dragging'),
    '#description' => t('Sometimes when the map covers big part of touch device screen draggable feature can cause inability to scroll the page'),
    '#default_value' => $this->options['styled_google_map_view_mobile_draggable'],
  );
  $form['styled_google_map_view_streetviewcontrol'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable street view control'),
    '#default_value' => $this->options['styled_google_map_view_streetviewcontrol'],
  );
  $form['styled_google_map_view_zoomcontrol'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable zoom control'),
    '#default_value' => $this->options['styled_google_map_view_zoomcontrol'],
  );
  $form['styled_google_map_view_scrollwheel'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable scrollwheel'),
    '#default_value' => $this->options['styled_google_map_view_scrollwheel'],
  );
  $form['map_center'] = array(
    '#type' => 'fieldset',
    '#title' => t('Centering map'),
    '#description' => t('Specify the longitude and latitude coordinates to center the map'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['map_center']['styled_google_map_view_center_coordinates_lat'] = array(
    '#title' => t('Latitude'),
    '#type' => 'textfield',
    '#default_value' => $this->options['map_center']['styled_google_map_view_center_coordinates_lat'],
  );
  $form['map_center']['styled_google_map_view_center_coordinates_lon'] = array(
    '#title' => t('longitude'),
    '#type' => 'textfield',
    '#default_value' => $this->options['map_center']['styled_google_map_view_center_coordinates_lon'],
  );
  $form['popup'] = array(
    '#type' => 'fieldset',
    '#title' => t('Popup Styling'),
    '#description' => t('All settings for the popup exposed by the library. If you want more flexibility in your the styling of the popup. You can use the CSS defined classes'),
    '#collapsed' => TRUE,
    '#collapsible' => TRUE,
  );
  $form['popup']['styled_google_map_view_shadow_style'] = array(
    '#type' => 'select',
    '#title' => t('Shadow style'),
    '#options' => array(
      0,
      1,
      2,
    ),
    '#description' => t('1: shadow behind, 2: shadow below, 0: no shadow'),
    '#default_value' => $this->options['popup']['styled_google_map_view_shadow_style'] ? $this->options['popup']['styled_google_map_view_shadow_style'] : $this->options['styled_google_map_view_shadow_style'],
  );
  $form['popup']['styled_google_map_view_padding'] = array(
    '#type' => 'textfield',
    '#title' => t('Padding'),
    '#field_suffix' => 'px',
    '#default_value' => $this->options['popup']['styled_google_map_view_padding'] ? $this->options['popup']['styled_google_map_view_padding'] : $this->options['styled_google_map_view_padding'],
  );
  $form['popup']['styled_google_map_view_border_radius'] = array(
    '#type' => 'textfield',
    '#title' => t('Border radius'),
    '#field_suffix' => 'px',
    '#default_value' => $this->options['popup']['styled_google_map_view_border_radius'] ? $this->options['popup']['styled_google_map_view_border_radius'] : $this->options['styled_google_map_view_border_radius'],
  );
  $form['popup']['styled_google_map_view_border_width'] = array(
    '#type' => 'textfield',
    '#title' => t('Border width'),
    '#field_suffix' => 'px',
    '#default_value' => $this->options['popup']['styled_google_map_view_border_width'] ? $this->options['popup']['styled_google_map_view_border_width'] : $this->options['styled_google_map_view_border_width'],
  );
  $form['popup']['styled_google_map_view_border_color'] = array(
    '#type' => 'textfield',
    '#title' => t('Border color'),
    '#field_suffix' => '#hex',
    '#default_value' => $this->options['popup']['styled_google_map_view_border_color'] ? $this->options['popup']['styled_google_map_view_border_color'] : $this->options['styled_google_map_view_border_color'],
  );
  $form['popup']['styled_google_map_view_background_color'] = array(
    '#type' => 'textfield',
    '#title' => t('Background color'),
    '#field_suffix' => '#hex',
    '#default_value' => $this->options['popup']['styled_google_map_view_background_color'] ? $this->options['popup']['styled_google_map_view_background_color'] : $this->options['styled_google_map_view_background_color'],
  );
  $form['popup']['styled_google_map_view_min_width'] = array(
    '#type' => 'textfield',
    '#title' => t('Min width'),
    '#field_suffix' => 'px (or auto)',
    '#default_value' => $this->options['popup']['styled_google_map_view_min_width'] ? $this->options['popup']['styled_google_map_view_min_width'] : $this->options['styled_google_map_view_min_width'],
  );
  $form['popup']['styled_google_map_view_max_width'] = array(
    '#type' => 'textfield',
    '#title' => t('Max width'),
    '#field_suffix' => 'px (or auto)',
    '#default_value' => $this->options['popup']['styled_google_map_view_max_width'] ? $this->options['popup']['styled_google_map_view_max_width'] : $this->options['styled_google_map_view_max_width'],
  );
  $form['popup']['styled_google_map_view_min_height'] = array(
    '#type' => 'textfield',
    '#title' => t('Min height'),
    '#field_suffix' => 'px (or auto)',
    '#default_value' => $this->options['popup']['styled_google_map_view_min_height'] ? $this->options['popup']['styled_google_map_view_min_height'] : $this->options['styled_google_map_view_min_height'],
  );
  $form['popup']['styled_google_map_view_max_height'] = array(
    '#type' => 'textfield',
    '#title' => t('Max height'),
    '#field_suffix' => 'px (or auto)',
    '#default_value' => $this->options['popup']['styled_google_map_view_max_height'] ? $this->options['popup']['styled_google_map_view_max_height'] : $this->options['styled_google_map_view_max_height'],
  );
  $form['popup']['styled_google_map_view_arrow_style'] = array(
    '#type' => 'select',
    '#title' => t('Arrow style'),
    '#options' => array(
      0,
      1,
      2,
    ),
    '#description' => t('1: left side visible, 2: right side visible, 0: both sides visible'),
    '#default_value' => $this->options['popup']['styled_google_map_view_arrow_style'] ? $this->options['popup']['styled_google_map_view_arrow_style'] : $this->options['styled_google_map_view_arrow_style'],
  );
  $form['popup']['styled_google_map_view_arrow_size'] = array(
    '#type' => 'textfield',
    '#title' => t('Arrow size'),
    '#field_suffix' => 'px',
    '#default_value' => $this->options['popup']['styled_google_map_view_arrow_size'] ? $this->options['popup']['styled_google_map_view_arrow_size'] : $this->options['styled_google_map_view_arrow_size'],
  );
  $form['popup']['styled_google_map_view_arrow_position'] = array(
    '#type' => 'textfield',
    '#title' => t('Arrow position'),
    '#field_suffix' => 'px',
    '#default_value' => $this->options['popup']['styled_google_map_view_arrow_position'] ? $this->options['popup']['styled_google_map_view_arrow_position'] : $this->options['styled_google_map_view_arrow_position'],
  );
  $form['popup']['styled_google_map_view_second_click'] = array(
    '#title' => t('Close popup on second mouse click'),
    '#type' => 'select',
    '#options' => array(
      '1' => t('Yes'),
      '0' => t('No'),
    ),
    '#default_value' => $this->options['popup']['styled_google_map_view_second_click'] ? $this->options['popup']['styled_google_map_view_second_click'] : $this->options['styled_google_map_view_second_click'],
  );
  $form['popup']['styled_google_map_view_disable_auto_pan'] = array(
    '#type' => 'select',
    '#title' => t('Disable Auto pan'),
    '#options' => array(
      TRUE => t('Yes'),
      FALSE => t('No'),
    ),
    '#description' => t('Automatically center the pin on click'),
    '#default_value' => $this->options['popup']['styled_google_map_view_disable_auto_pan'] ? $this->options['popup']['styled_google_map_view_disable_auto_pan'] : $this->options['styled_google_map_view_disable_auto_pan'],
  );
  $form['popup']['styled_google_map_view_hide_close_button'] = array(
    '#type' => 'select',
    '#title' => t('Hide close button'),
    '#options' => array(
      TRUE => t('Yes'),
      FALSE => t('No'),
    ),
    '#description' => t('Hide the popup close button'),
    '#default_value' => $this->options['popup']['styled_google_map_view_hide_close_button'] ? $this->options['popup']['styled_google_map_view_hide_close_button'] : $this->options['styled_google_map_view_hide_close_button'],
  );
  $form['popup']['styled_google_map_view_disable_animation'] = array(
    '#type' => 'select',
    '#title' => t('Disable animation'),
    '#options' => array(
      TRUE => t('Yes'),
      FALSE => t('No'),
    ),
    '#description' => t('Disables the popup animation'),
    '#default_value' => $this->options['popup']['styled_google_map_view_disable_animation'] ? $this->options['popup']['styled_google_map_view_disable_animation'] : $this->options['styled_google_map_view_disable_animation'],
  );
  $form['popup_classes'] = array(
    '#type' => 'fieldset',
    '#title' => t('Popup classes'),
    '#collapsed' => TRUE,
    '#collapsible' => TRUE,
    '#description' => t('CSS classes for easy popup styling'),
  );
  $form['popup_classes']['styled_google_map_view_content_container_class'] = array(
    '#type' => 'textfield',
    '#title' => t('Wrapper class'),
    '#default_value' => $this->options['popup_classes']['styled_google_map_view_content_container_class'] ? $this->options['popup_classes']['styled_google_map_view_content_container_class'] : $this->options['styled_google_map_view_content_container_class'],
  );
  $form['popup_classes']['styled_google_map_view_background_class'] = array(
    '#type' => 'textfield',
    '#title' => t('Background class'),
    '#default_value' => $this->options['popup_classes']['styled_google_map_view_background_class'] ? $this->options['popup_classes']['styled_google_map_view_background_class'] : $this->options['styled_google_map_view_background_class'],
  );
  $form['popup_classes']['styled_google_map_view_arrow_class'] = array(
    '#type' => 'textfield',
    '#title' => t('Arrow class'),
    '#default_value' => $this->options['popup_classes']['styled_google_map_view_arrow_class'] ? $this->options['popup_classes']['styled_google_map_view_arrow_class'] : $this->options['styled_google_map_view_arrow_class'],
  );
  $form['popup_classes']['styled_google_map_view_arrow_outer_class'] = array(
    '#type' => 'textfield',
    '#title' => t('Arrow outer class'),
    '#default_value' => $this->options['popup_classes']['styled_google_map_view_arrow_outer_class'] ? $this->options['popup_classes']['styled_google_map_view_arrow_outer_class'] : $this->options['styled_google_map_view_arrow_outer_class'],
  );
  $form['popup_classes']['styled_google_map_view_arrow_inner_class'] = array(
    '#type' => 'textfield',
    '#title' => t('Arrow inner class'),
    '#default_value' => $this->options['popup_classes']['styled_google_map_view_arrow_inner_class'] ? $this->options['popup_classes']['styled_google_map_view_arrow_inner_class'] : $this->options['styled_google_map_view_arrow_inner_class'],
  );
}