You are here

public function ip_geoloc_plugin_style_openlayers::options_form in IP Geolocation Views & Maps 7

Create the options form.

Overrides views_plugin_style::options_form

File

views/ip_geoloc_plugin_style_openlayers.inc, line 41

Class

ip_geoloc_plugin_style_openlayers

Code

public function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $form['map'] = array(
    '#type' => 'select',
    '#title' => t('Map'),
    '#description' => t('The OpenLayers map used to place the view locations on. You can configure map and markers <a href="!url">here</a>.', array(
      '!url' => url('admin/structure/openlayers/maps'),
    )),
    '#options' => openlayers_map_options(),
    // removed in OpenLayers3
    '#default_value' => isset($this->options['map']) ? $this->options['map'] : variable_get('openlayers_default_map', 'default'),
  );
  $form_state['renderer'] = 'openlayers';
  $weight = 10;
  ip_geoloc_plugin_style_bulk_of_form($this, $weight, $form, $form_state);

  // OpenLayers has "Hide empty map for Views" for this.
  unset($form['empty_map_center']);
  $form['center_option']['#options'][IP_GEOLOC_MAP_CENTER_ON_LOCATION_FROM_ARGUMENT] = t('Use lat/lon coordinate arguments from a contextual filter');
  $argument_handlers = $this->view->display_handler
    ->get_handlers('argument');
  if (!empty($argument_handlers)) {
    $argument_options = array(
      '' => '<' . t('none') . '>',
    );
    foreach ($argument_handlers as $key => $handler) {
      $argument_options[$key] = $handler->definition['group'] . ': ' . $handler->definition['title'];
    }
    $form['argument'] = array(
      '#type' => 'select',
      '#title' => t('Choose a contextual filter to pull data from'),
      '#options' => $argument_options,
      '#default_value' => $this->options['argument'],
      '#weight' => 100,
    );
  }
}