You are here

function gmap_widget_setup in GMap Module 7

Same name and namespace in other branches
  1. 5 gmap.module \gmap_widget_setup()
  2. 6.2 gmap.module \gmap_widget_setup()
  3. 6 gmap.module \gmap_widget_setup()
  4. 7.2 gmap.module \gmap_widget_setup()

Set up widget. This function will change a form element's ID so it is found by the GMap handlers system.

Parameters

&$element: The form element to modify.

$type: The gmap widget type to map to.

$map: The map id. If not defined, $element['#map'] will be used.

Return value

None.

7 calls to gmap_widget_setup()
gmap_admin_settings in ./gmap_settings_ui.inc
@file GMap settings form.
gmap_macro_builder_form in ./gmap_macro_builder.module
Macro builder form.
gmap_set_location in ./gmap.module
Location chooser utility function.
process_gmap_address in ./gmap.module
Address widget #process function.
process_gmap_control in ./gmap.module
Generic gmap control #process function.

... See full list

File

./gmap.module, line 1068
GMap -- Routines to use the Google Maps API in Drupal.

Code

function gmap_widget_setup(&$element, $type, $map = NULL) {
  if (!$map) {
    if (isset($element['#map'])) {
      $map = $element['#map'];
    }
    else {

      // Hmm, missing #map. Try to figure it out.
      if (isset($element['#gmap_settings']['id'])) {
        $map = $element['#gmap_settings']['id'];
      }
    }
  }
  if (!isset($element['#attributes']['class'])) {
    $element['#attributes']['class'] = array();
  }
  $element['#attributes']['class'] = array_merge($element['#attributes']['class'], array(
    'gmap-control',
    'gmap-' . $type,
  ));
  $element['#id'] = gmap_get_id($map, $type);
  $element['#map'] = $map;
}