Newer
Older
'#title'=>t('Default Line 2 Color'),
'#default_value'=>GMAP_LINECOLOR2,
'#size'=>25,
'#maxlength'=>7 ,
);
$form['defaults']['gmap_default_line3_color']=array(
'#type'=>'textfield',
'#title'=>t('Default Line 3 Color'),
'#default_value'=>GMAP_LINECOLOR3,
'#size'=>25,
'#maxlength'=>7 ,
);
$form['location']=array(
'#type' => 'fieldset',
'#title' => t('Location settings'),
);
$form['location']['gmap_location_map']=array(
'#type'=>'textfield',
'#title'=>t('Default location map'),
'#default_value'=>variable_get('gmap_location_map','[gmap|id=locmap|center=40,0|zoom=3|width=100%|height=400px]'),
'#description'=>t('The gmap macro for the map to be used in the location.module for setting latitude and longitude.'),
);
return $form;
drupal_add_js(drupal_get_path('module','gmap'). '/gmapmacro.js');
return gmap_macro_form();
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
function gmap_macro_form() {
$form['macroform'] = array(
'#type' => 'fieldset',
'#title' => t('Gmap macro creation'),
'#theme' => 'gmap_macro',
);
$linecolors = array(GMAP_LINECOLOR1, GMAP_LINECOLOR2, GMAP_LINECOLOR3);
$form['macroform']['mapdiv']=array('#type'=>'markup','#value'=>'<div id="map" style="width: '.GMAP_WIDTH.'; height: '.GMAP_HEIGHT.';"></div>');
$form['macroform']['javascript'] = array(
'#value' => drupal_call_js('gmap_set_line_colors', $linecolors),
);
$form['macroform']['mapid'] = array(
'#type' => 'textfield',
'#id' => 'gmap-mapid',
'#title' => t('Map id attribute'),
'#default_value' => variable_get('gmap_default_mapid', 'map'),
'#attributes' => array('onchange' => 'set_gmap_mapid(this.value)'),
);
$form['macroform']['maptype'] = array(
'#type' => 'select',
'#id' => 'gmap-maptype',
'#title' => t('Map type'),
'#options' => drupal_map_assoc(array('Map', 'Satellite', 'Hybrid')),
'#default_value' => GMAP_TYPE,
'#required' => FALSE,
'#attributes' => array('onchange' => 'set_gmap_type(this.value);'),
);
$form['macroform']['controltype'] = array(
'#type' => 'select',
'#id' => 'gmap-controltype',
'#title' => t('Controls'),
'#options' => drupal_map_assoc(array('None', 'Small', 'Large')),
'#required' => FALSE,
'#default_value' => GMAP_CONTROL,
'#attributes' => array('onchange' => 'set_control_type(this.value);')
);
'#type' => 'textfield',
'#id' => 'gmap-latlong',
'#title' => t('The Latitude and Longitude of the centre of the map'),
'#default_value' => GMAP_LONGLAT,
'#size' => 50,
'#attributes' => array('onchange' => 'set_gmap_latlong(this.value);'),
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
);
$form['macroform']['width'] = array(
'#type' => 'textfield',
'#id' => 'gmap-width',
'#title' => t('Map width'),
'#default_value' => GMAP_WIDTH,
'#size' => 25,
'#attributes' => array('onchange' => 'set_gmap_dimension(this, \'width\');'),
);
$form['macroform']['height'] = array(
'#type' => 'textfield',
'#title' => t('Map height'),
'#id' => 'gmap-height',
'#default_value' => GMAP_HEIGHT,
'#size' => 25,
'#attributes' => array('onchange' => 'set_gmap_dimension(this, \'height\');'),
);
$form['macroform']['alignment'] = array(
'#type' => 'select',
'#id' => 'gmap-alignment',
'#title' => t('Alignment'),
'#options' => drupal_map_assoc(array('None', 'Right', 'Left', 'Center')),
// '#default_value' => GMAP_ALIGNMENT,
'#required' => FALSE,
'#attributes' => array('onchange' => 'set_gmap_alignment(this.value);')
);
$form['macroform']['clicktype'] = array(
'#type' => 'select',
'#id' => 'gmap-clicktype',
'#title' => t('What happens when you click on the map'),
'#options' => drupal_map_assoc(array('Points', 'Line1', 'Line2', 'Line3')),
'#required' => FALSE,
'#default_value' => 'Points',
// '#attributes' => array('onchange' => 'docontrol(this.value);')
);
$form['macroform']['zoom'] = array(
'#type' => 'select',
'#id' => 'gmap-zoom',
'#title' => t('The current magnification of the map'),
'#default_value' => GMAP_ZOOM,
'#options' => drupal_map_assoc(range(0, 17)),
'#attributes' => array('onchange' => 'setgmapZoom(this.value);'),
);
$form['macroform']['textarea'] = array(
'#type' => 'textarea',
'#id' => 'gmap-macrotext',
'#title' => t('Macro text'),
);
return drupal_get_form('macroform', $form);
}
/**
* Implementation of hook_views_style_plugins()
*/
function gmap_views_style_plugins() {
return array(
'gmap' => array(
'name' => t('Gmap View'),
'theme' => 'views_view_gmap',
'needs_fields' => true,
'validate' => 'views_ui_plugin_validate_list',
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
}
/**
* Display the nodes of a view in a Google Map
*/
function theme_views_view_gmap($view, $nodes) {
$fields = _views_get_fields();
foreach ($nodes as $node) {
$node_data = node_load(array("nid"=>$node->nid));
$location = $node_data->location;
$newmarker['label'] = '';
foreach ($view->field as $field) {
$newmarker['label'] .= "<p>" . views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node) . "</p>";
}
$newmarker['point']= $location['lat'] . ',' . $location['lon'];
$newmarker['markername']='drupal_view';
$thismap['markers'][]= $newmarker;
}
$output .= gmap_draw_map($thismap);
return $output;
}