You are here

function openlayers_ui_get_layer_options in Openlayers 7.2

Same name and namespace in other branches
  1. 6.2 modules/openlayers_ui/openlayers_ui.module \openlayers_ui_get_layer_options()

Get layer options.

Parameters

String $type:

openlayers_projection $projection:

1 call to openlayers_ui_get_layer_options()
openlayers_maps_ui::edit_form in modules/openlayers_ui/plugins/export_ui/openlayers_maps_ui.class.php
Provide the actual editing form.

File

modules/openlayers_ui/openlayers_ui.module, line 221
Main Drupal module file for the OpenLayers UI module

Code

function openlayers_ui_get_layer_options($type = 'baselayer', $projection = NULL) {
  $options = array();
  $layers = array();

  // Get layers in an array
  foreach (openlayers_layers_load() as $l) {
    $layers[$l->name] = openlayers_get_layer_object($l);
  }

  // Go through layers to theme output.
  foreach ($layers as $key => $layer) {
    if (!is_object($layer)) {

      // Failure was already logged in openlayers_get_layer_object
      continue;
    }

    // not filtering by projection
    // this layer has an appropriate projection
    // this layer can be reprojected because it is vector
    $variables = array();
    if (!isset($projection) || in_array($projection, $layer
      ->getProjections()) || !empty($layer->data['vector'])) {
      if (!array_key_exists('isBaseLayer', $layer->data)) {
        throw new Exception("Layer definition {$key} lacks isBaseLayer attribute");
      }
      if ($layer->data['isBaseLayer'] == TRUE && $type == 'baselayer') {
        $variables = array(
          'layer_title' => $layer->title,
          'layer_description' => $layer->description,
          'layer_link' => 'admin/structure/openlayers/layers/list/' . $layer->name . '/edit',
        );
      }
      if ($layer->data['isBaseLayer'] == FALSE && $type == 'overlay') {
        $variables = array(
          'layer_title' => $layer->title,
          'layer_description' => $layer->description,
          'layer_link' => 'admin/structure/openlayers/layers/list/' . $layer->name . '/edit',
        );
        if ($layer->data['layer_type'] == 'openlayers_views_vector') {
          $variables['layer_link'] = 'admin/structure/views/view/' . $layer->data['views']['view'] . '/edit/' . $layer->data['views']['display'];
        }
      }
    }
    if (!empty($variables)) {
      $options[$key] = theme('openlayers_ui_form_layer_description', $variables);
    }
  }
  return $options;
}