You are here

function simple_gmap_field_formatter_settings_form in Simple Google Maps 7

Implements hook_field_formatter_settings_form().

File

./simple_gmap.module, line 148
Simple Google Maps module.

Code

function simple_gmap_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $type = $display['type'];
  $element['embedded_label'] = array(
    '#type' => 'markup',
    '#markup' => '<h3>' . t('Embedded map') . '</h3>',
  );
  $element['include_map'] = array(
    '#type' => 'checkbox',
    '#title' => t('Include embedded dynamic map'),
    '#default_value' => (int) $settings['include_map'],
  );
  $element['include_static_map'] = array(
    '#type' => 'checkbox',
    '#title' => t('Include embedded static map'),
    '#default_value' => isset($settings['include_static_map']) ? (int) $settings['include_static_map'] : 0,
  );
  $element['apikey'] = array(
    '#type' => 'textfield',
    '#title' => t('Google Maps API key'),
    '#default_value' => check_plain($settings['apikey']),
    '#description' => t('Static Maps will not work without an API key. See the <a href="https://developers.google.com/maps/documentation/static-maps" target="_blank">Static Maps API page</a> to learn more and obtain a key.'),
  );
  $element['iframe_width'] = array(
    '#title' => t('Width of embedded map'),
    '#type' => 'textfield',
    '#description' => t('You can set sizes in px or percent (ex: 600px or 100%). Note that static maps only accept sizes in pixels, without the suffix px (ex: 600).'),
    '#default_value' => check_plain($settings['iframe_width']),
  );
  $element['iframe_height'] = array(
    '#title' => t('Height of embedded map'),
    '#type' => 'textfield',
    '#description' => t('You can set sizes in px or percent (ex: 600px or 100%). Note that static maps only accept sizes in pixels, without the suffix px (ex: 600).'),
    '#default_value' => check_plain($settings['iframe_height']),
  );
  $element['static_scale'] = array(
    '#title' => t('Load Retina sized static image'),
    '#type' => 'select',
    '#description' => t('Choose "Yes" to double the width and height of the static image for use on retina displays. (Only applicable to static map)'),
    '#options' => array(
      1 => t('No'),
      2 => t('Yes'),
    ),
    '#default_value' => (int) $settings['static_scale'],
  );
  $element['link_label'] = array(
    '#type' => 'markup',
    '#markup' => '<h3>' . t('Link to map') . '</h3>',
  );
  $element['include_link'] = array(
    '#type' => 'checkbox',
    '#title' => t('Include link to map'),
    '#default_value' => (int) $settings['include_link'],
  );
  $element['link_text'] = array(
    '#title' => t('Link text'),
    '#type' => 'textfield',
    '#default_value' => check_plain($settings['link_text']),
    '#description' => t("Enter the text to use for the link to the map, or enter 'use_address' (without the quotes) to use the entered address text as the link text"),
  );
  $element['generic_label'] = array(
    '#type' => 'markup',
    '#markup' => '<h3>' . t('General settings') . '</h3>',
  );
  $element['zoom_level'] = array(
    '#title' => t('Zoom level'),
    '#type' => 'select',
    '#description' => t('Choose a default zoom level for embedded and linked maps'),
    '#options' => array(
      1 => t('1 - Minimum'),
      2 => 2,
      3 => 3,
      4 => 4,
      5 => 5,
      6 => 6,
      7 => 7,
      8 => 8,
      9 => 9,
      10 => 10,
      11 => 11,
      12 => 12,
      13 => 13,
      14 => t('14 - Default'),
      15 => 15,
      16 => 16,
      17 => 17,
      18 => 18,
      19 => 19,
      20 => t('20 - Maximum'),
    ),
    '#default_value' => (int) $settings['zoom_level'],
  );
  $element['include_text'] = array(
    '#type' => 'checkbox',
    '#title' => t('Include original address text'),
    '#default_value' => (int) $settings['include_text'],
  );
  $element['map_type'] = array(
    '#title' => t('Map type'),
    '#type' => 'select',
    '#description' => t('Choose a default map type for embedded and linked maps'),
    '#options' => array(
      'm' => t('Map'),
      'k' => t('Satellite'),
      'h' => t('Hybrid'),
      'p' => t('Terrain'),
    ),
    '#default_value' => check_plain($settings['map_type']),
  );
  $element['langcode'] = array(
    '#title' => t('Language'),
    '#type' => 'textfield',
    '#default_value' => check_plain($settings['langcode']),
    '#description' => t("Enter a two-letter language code that Google Maps can recognize, or enter 'page' (without the quotes) to use the current page's language code"),
  );
  return $element;
}