function geolocation_googlemaps_attach_google_js in Geolocation Field 7
Helper function that attaches JS to the given element.
Parameters
array $element: Element.
2 calls to geolocation_googlemaps_attach_google_js()
- geolocation_googlemaps_field_widget_form in modules/
geolocation_googlemaps/ geolocation_googlemaps.module - Implements hook_field_widget_form().
- geolocation_googlemaps_field_widget_form_alter in modules/
geolocation_googlemaps/ geolocation_googlemaps.module - Implements hook_field_widget_form_alter().
File
- modules/
geolocation_googlemaps/ geolocation_googlemaps.module, line 588 - Google Maps widget and formatters for Geolocation.
Code
function geolocation_googlemaps_attach_google_js(&$element) {
$js_added_already =& drupal_static(__FUNCTION__, FALSE);
if (!$js_added_already) {
$data = array();
$api_key = variable_get('geolocation_googlemaps_api_key', '');
if (!empty($api_key)) {
$data['key'] = $api_key;
}
$query = drupal_http_build_query($data);
$element['#attached']['js'][] = array(
'data' => '//maps.google.com/maps/api/js?' . $query,
'type' => 'external',
);
$element['#attached']['js'][] = array(
'data' => '//www.google.com/jsapi',
'type' => 'external',
);
$js_added_already = TRUE;
}
}