You are here

function openlayers_error_check_map in Openlayers 6.2

Same name and namespace in other branches
  1. 6 openlayers.module \openlayers_error_check_map()
  2. 7.2 openlayers.module \openlayers_error_check_map()

Checks map array for incompatibilities or errors.

Parameters

$map: Map array

$log_errors: Boolean whether to log errors.

Return value

FALSE if passed. Array of descriptive errors if fail.

1 call to openlayers_error_check_map()
openlayers_build_map in ./openlayers.module
Prepare a map for rendering.

File

./openlayers.module, line 724
Main OpenLayers API File

Code

function openlayers_error_check_map($map, $log_errors = TRUE) {
  $errors = array();

  // Check for layers
  if (!is_array($map['layers'])) {
    $errors[] = t('Map contains no renderable layers.');
  }
  else {

    // Check layer projections
    foreach ($map['layers'] as $layer) {
      openlayers_layer_sanity_check(array(
        'data' => $layer,
      ), $map['projection'], TRUE);
    }
  }

  // Check if any errors found to log
  if (count($errors) > 0 && $log_errors) {

    // Log the Error(s)
    watchdog('openlayers', implode(', ', $errors), array(), WATCHDOG_ERROR);
  }

  // Check if errors and return
  return count($errors) > 0 ? $errors : FALSE;
}