function location_views_map_input_form in Location 5
Function to create a gmap map form
2 calls to location_views_map_input_form()
- location_views_tables in contrib/
location_views/ location_views.module - For operation with the views.module.
- location_views_views_pre_view in contrib/
location_views/ location_views.module - Implementation of views_pre_view
File
- contrib/
location_views/ location_views.module, line 990 - Views-enables the location module.
Code
function location_views_map_input_form() {
$form = array();
if (!module_exists('gmap')) {
return $form;
}
$user = $GLOBALS['user'];
$res = db_query("SELECT * FROM {location} WHERE eid=%d AND type='user'", $user->uid);
if ($gmap_user = db_fetch_array($res)) {
$user->latitude = $gmap_user['latitude'];
$user->longitude = $gmap_user['longitude'];
}
$form['map'] = array(
'#type' => 'fieldset',
'#title' => t('Google Map'),
'#description' => t('Click on the map to mark the center point for your search, then submit the values.'),
);
$form['map']['gmap_user'] = array(
'#type' => 'markup',
'#value' => '',
);
$form['coordinates'] = array(
'#type' => 'fieldset',
'#title' => t('Coordinates'),
'#description' => t('The latitude and longitude will automatically be entered here (or you can do it manually).'),
);
$form['coordinates']['gmap_latitude'] = array(
'#type' => 'textfield',
'#id' => 'gmap-latitude',
'#title' => t('Latitude'),
'#default_value' => $_GET['edit']['gmap_latitude'] ? $_GET['edit']['gmap_latitude'] : $user->latitude,
'#size' => 30,
'#maxlength' => 120,
'#attributes' => array(
'onchange' => 'gmap_textchange();',
),
);
$form['coordinates']['gmap_longitude'] = array(
'#type' => 'textfield',
'#title' => t('Longitude'),
'#default_value' => $_GET['edit']['gmap_longitude'] ? $_GET['edit']['gmap_longitude'] : $user->longitude,
'#size' => 30,
'#maxlength' => 120,
'#attributes' => array(
'onchange' => 'gmap_textchange();',
),
);
$form['map']['gmap_user']['#value'] = gmap_set_location(variable_get('gmap_user_map', '[gmap|id=usermap|center=0,30|control=Large|zoom=16|width=100%|height=400px]'), $form['coordinates']['gmap_longitude'], $form['coordinates']['gmap_latitude']);
return $form;
}