You are here

function _openlayers_cck_render_element_map in Openlayers 6.2

Same name and namespace in other branches
  1. 6 modules/openlayers_cck/openlayers_cck.module \_openlayers_cck_render_element_map()

Render Map for Widget

Parameters

$field_name: CCK name of field

$values: Current default values

$field: Array of field data

Return value

Rendered map array

1 call to _openlayers_cck_render_element_map()
openlayers_cck_wkt_element_process in modules/openlayers_cck/openlayers_cck.module
Process an individual element.

File

modules/openlayers_cck/openlayers_cck.module, line 474
This file holds the main Drupal hook functions and private functions for the openlayers_cck module.

Code

function _openlayers_cck_render_element_map($field_name = '', $field_label = '', $values = array(), $field = array()) {
  $field_id = 'edit-' . str_replace('_', '-', $field_name) . '-openlayers-wkt';

  // Get map to use for field
  if (isset($field['widget']['openlayers_cck_preset_map'])) {
    $preset = openlayers_preset_load($field['widget']['openlayers_cck_preset_map']);
    $map = $preset->data;
  }
  else {
    $preset = openlayers_preset_load(variable_get('openlayers_default_preset', 'default'));
    $map = $preset->data;
  }
  $map['id'] = OPENLAYERS_CCK_WIDGET_MAP_ID_PREFIX . '-' . $field_name;
  if ($field['multiple'] == 0) {
    $limit = 1;
  }
  elseif ($field['multiple'] > 1) {
    $limit = $field['multiple'];
  }
  else {
    $limit = 0;
  }

  // Make sure that our display projection matches the database projection
  // TODO: rewrite
  $map['behaviors']['openlayers_behavior_drawfeatures'] = array(
    'element_id' => $field_id,
    'feature_types' => $field['openlayers_cck_feature_types'],
    'feature_limit' => $limit,
  );
  return openlayers_render_map($map);
}