You are here

function openlayers_process_layers in Openlayers 6

Process Layers

Call back to process layers provided by the openlayers_openlayers_layers_info() function

Parameters

$layer: String ID for the layer

Return value

Array formated for an OpenLayers map layer

2 string references to 'openlayers_process_layers'
hook_openlayers_layers_info in docs/openlayers.api.php
OpenLayers Layers Info
openlayers_openlayers_layers_info in ./openlayers.module
Implementation of hook_openlayers_layers_info().

File

includes/openlayers.layers.inc, line 21
This file contains layer instances for the default openlayers WMS

Code

function openlayers_process_layers($layer = NULL) {
  $layer_data = array();

  // Make sure layer is a string
  if (!is_string($layer)) {
    return FALSE;
  }

  // Get info array to reference title
  $layer_info = openlayers_openlayers_layers_info();

  // Determine what data to send back
  switch ($layer) {
    case 'openlayers_default_wms':
      $layer_data = array(
        'id' => $layer,
        'type' => 'WMS',
        'name' => $layer_info[$layer]['name'],
        'description' => $layer_info[$layer]['description'],
        'projection' => $layer_info[$layer]['projection'],
        'baselayer' => $layer_info[$layer]['baselayer'],
        'url' => 'http://labs.metacarta.com/wms/vmap0',
        'params' => array(
          'layers' => 'basic',
        ),
        'options' => array(),
        'events' => array(),
      );

      // If baselayer is set to false, we need to ask WMS for a transparent layer.
      // If the user has set transparency explicitly, we do not ovverride.
      if ($layer_data['baselayer'] == FALSE && !isset($layer_data['params']['transparent'])) {
        $layer_data['params']['transparent'] = TRUE;
      }
      break;
  }
  return $layer_data;
}