You are here

function hook_openlayers_layers_info in Openlayers 6

OpenLayers Layers Info

This hook tells OpenLayers about the available layers that can be used by name in maps. Layers can still be defined manually, but this allows for easy calling of layers, and these will show up in the Preset UI.

Return value

Return a nested associative array with the top level being a unique string identifier, and the nested array containing the following key/pairs:

  • "name": Translated name of the layer. This will show up in the Preset UI.
  • "description": Translates description.
  • "file": The Drupal path for where the callback is stored
  • "callback": The name of the PHP function that will be called when the layer is rendered
  • "projection": An array of projections that the layer is compatible with. Leave empty if compatible with all.
  • "baselayer": Boolean whether the layer is a base layer or not.
2 functions implement hook_openlayers_layers_info()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

openlayers_layers_openlayers_layers_info in modules/openlayers_layers/openlayers_layers.module
Implementation of hook_openlayers_layers_info().
openlayers_openlayers_layers_info in ./openlayers.module
Implementation of hook_openlayers_layers_info().
1 invocation of hook_openlayers_layers_info()
openlayers_layers_get_info in ./openlayers.module
Get Layer Info

File

docs/openlayers.api.php, line 97
Hooks provided by the OpenLayers suite of modules.

Code

function hook_openlayers_layers_info() {

  // Taken from openlayers.module
  // Define info array
  $info['openlayers_default_wms'] = array(
    'name' => t('Default OpenLayers WMS'),
    'description' => t('A simple basemap to get you started'),
    'file' => drupal_get_path('module', 'openlayers') . '/includes/openlayers.layers.inc',
    'callback' => 'openlayers_process_layers',
    'projection' => array(
      '4326',
      '900913',
      '4269',
    ),
    'baselayer' => TRUE,
  );
  return $info;
}