You are here

function hook_openlayers_presets in Openlayers 6

Same name and namespace in other branches
  1. 6.2 docs/openlayers.api.php \hook_openlayers_presets()

OpenLayers Presets

This hook lets other modules define map presets that the user can choose from in various places, or clone.

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:

  • "preset_name": Unique string with only lowercase characters and underscores.
  • "preset_title": Translated title to be used listing presets.
  • "preset_description": Translated description.
  • "preset_data": The unrenderd map array
2 functions implement hook_openlayers_presets()

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

openlayers_openlayers_presets in ./openlayers.module
Implementation of hook_openlayers_presets().
openlayers_test_openlayers_presets in tests/openlayers_test.module
Implementation of hook_openlayers_presets().
3 invocations of hook_openlayers_presets()
openlayers_features_export in includes/openlayers.features.inc
Implementation of hook_features_export().
openlayers_features_revert in includes/openlayers.features.inc
Implementation of hook_features_revert().
openlayers_presets in ./openlayers.module
Get Presets Array

File

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

Code

function hook_openlayers_presets() {

  // Taken from openlayers.module
  $presets = array();

  // Create map array
  $default_map = array(
    'projection' => '4326',
    'width' => 'auto',
    'default_layer' => 'openlayers_default_wms',
    'height' => '300px',
    'center' => array(
      'lat' => '0',
      'lon' => '0',
      'zoom' => '2',
    ),
    'options' => array(
      'displayProjection' => '4326',
    ),
    'controls' => array(
      'LayerSwitcher' => TRUE,
      'Navigation' => TRUE,
      'PanZoomBar' => TRUE,
      'MousePosition' => TRUE,
    ),
  );

  // Create full preset array
  $presets['default'] = array(
    'preset_name' => 'default',
    'preset_title' => t('Default Map'),
    'preset_description' => t('This is the default map preset that comes with the OpenLayers module.'),
    'preset_data' => $default_map,
  );
  return $presets;
}