You are here

function openlayers_map_get_info in Openlayers 8.4

Get all available Leaflet map definitions.

Parameters

string $map: The specific map definition string.

Return value

array The leaflet maps definition array.

File

./openlayers.module, line 32
Contains the openlayers.module file.

Code

function openlayers_map_get_info($map = NULL) {
  static $drupal_static_fast;
  if (!isset($drupal_static_fast)) {
    $drupal_static_fast['leaflet_map_info'] =& drupal_static(__FUNCTION__);
  }
  $map_info =& $drupal_static_fast['leaflet_map_info'];
  if (empty($map_info)) {
    if ($cached = \Drupal::cache()
      ->get('leaflet_map_info')) {
      $map_info = $cached->data;
    }
    else {
      $map_info = \Drupal::moduleHandler()
        ->invokeAll('leaflet_map_info');

      // Let other modules alter the map info.
      \Drupal::moduleHandler()
        ->alter('leaflet_map_info', $map_info);
      \Drupal::cache()
        ->set('leaflet_map_info', $map_info);
    }
  }
  if (empty($map)) {
    return $map_info;
  }
  else {
    return isset($map_info[$map]) ? $map_info[$map] : [];
  }
}