openlayers_render_map

openlayers/openlayers.module, line 163

Versions
6
openlayers_render_map($map = array(), $render = TRUE)

Render Map

Given perimeters, render an OpenLayers map

Parameters

$map Associative array of map paramters

$render Boolean whether to fully render (include theme and JS)

Return value

Boolean if successful

Related topics

▾ 12 functions call openlayers_render_map()

openlayers_admin_default_settings in openlayers/includes/openlayers.defaults.inc
Menu callback; Displays the openlayers module default settings page.
openlayers_admin_default_settings in openlayers/includes/openlayers.defaults.inc
Menu callback; Displays the openlayers module default settings page.
openlayers_cck_widget in openlayers/modules/openlayers_cck/openlayers_cck.module
Implementation of hook_widget().
openlayers_cck_widget in openlayers/modules/openlayers_cck/openlayers_cck.module
Implementation of hook_widget().
theme_openlayers_cck_formatter_openlayersmapformatter_grouped in openlayers/modules/openlayers_cck/openlayers_cck.module
Theme a group of fields using just one map. Each field is given one layer.
theme_openlayers_cck_formatter_openlayersmapformatter_grouped in openlayers/modules/openlayers_cck/openlayers_cck.module
Theme a group of fields using just one map. Each field is given one layer.
theme_openlayers_cck_formatter_openlayersmapformatter_single in openlayers/modules/openlayers_cck/openlayers_cck.module
Theme a fields using a map. Each field is given a map.
theme_openlayers_cck_formatter_openlayersmapformatter_single in openlayers/modules/openlayers_cck/openlayers_cck.module
Theme a fields using a map. Each field is given a map.
_openlayers_map_form in openlayers/includes/openlayers.form.inc
Get OpenLayers Form
_openlayers_map_form in openlayers/includes/openlayers.form.inc
Get OpenLayers Form
_openlayers_map_form_validate in openlayers/includes/openlayers.form.inc
OpenLayers Form Validate
_openlayers_map_form_validate in openlayers/includes/openlayers.form.inc
OpenLayers Form Validate

Code

<?php
function openlayers_render_map($map = array(), $render = TRUE) {
  // Check array
  if (!is_array($map)) {
    return FALSE;
  }
  
  // Intialize
  if (openlayers_intialize() == FALSE) {
    return FALSE;
  }
  
  // Check ID
  if (!$map['id']) {
    $map['id'] = _openlayers_create_map_id();
  }
  
  // If the map does not specify that it does not want to merge
  // in the default layers, then merge in defaults
  if (!$map['only_these_layers']) {
    $saved_defaults = variable_get('openlayers_defaults', array());
    $map = openlayers_merge_maps($saved_defaults, $map);
  }
  
  // Merge with module/system defaults
  $system_defaults = _openlayers_get_map_defaults();
  $map = openlayers_merge_maps($system_defaults, $map);
  
  // Process layers
  $map['layers'] = _openlayers_layers_process($map['layers'], $map);
  // Process behaviors
  $map['behaviors'] = _openlayers_behaviors_process($map['behaviors'], $map);
  
  // Hook for one last alter
  // hook_openlayers_map_alter(&$map = array())
  drupal_alter('openlayers_map', &$map);
  
  // Check our map for errors
  $map['errors'] = openlayers_error_check_map($map);
  // Add JS and theme if no errors found
  if (!$map['errors'] || $render == FALSE) {
    // Add map container to drupal JS settings
    $openlayers = array(
      'openlayers' => array(
        'maps' => array(
          $map['id'] => $map,
        ),
      ),
    );
    drupal_add_js($openlayers, 'setting');
    
    // Add themed HTML (no need for it to go to JS)
    $map['themed'] = theme('openlayers_map', $map);
  }
  
  // Return map with or without errors
  return $map;
}
?>