You are here

function openlayers_ui_get_layer_options in Openlayers 6.2

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

Get layer options.

1 call to openlayers_ui_get_layer_options()
openlayers_ui_presets_form in modules/openlayers_ui/includes/openlayers_ui.presets.inc
Menu Callback for Add Preset

File

modules/openlayers_ui/openlayers_ui.module, line 632

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) {

    // not filtering by projection
    // this layer has an appropriate projection
    // this layer can be reprojected because it is vector
    if (!isset($projection) || in_array($projection, $layer->data['projection']) || !empty($layer->data['vector'])) {
      if ($type == 'baselayer' && $layer->data['baselayer']) {
        $options[$key] = theme('openlayers_ui_form_layer_description', $layer->title, $layer->description);
      }
      elseif ($type != 'baselayer' && empty($layer->data['baselayer'])) {
        $options[$key] = theme('openlayers_ui_form_layer_description', $layer->title, $layer->description);
      }
    }
  }
  return $options;
}