Newer
Older
'#title'=>t('Default width'),
'#default_value'=>GMAP_WIDTH,
'#size'=>25,
'#maxlength'=>6,
'#description'=>t('The default width of a Google map.'),
);
$form['defaults']['gmap_default_height']=array(
'#type'=>'textfield',
'#title'=>t('Default height'),
'#default_value'=>GMAP_HEIGHT,
'#size'=>25,
'#maxlength'=>6,
'#description'=>t('The default height of a Google map.'),
);
$form['defaults']['gmap_default_latlong']=array(
'#type'=>'textfield',
'#title'=>t('Default center'),
'#default_value'=>GMAP_LONGLAT,
'#description'=>'The decimal latitude,longitude of the centre of the map. The "." is used for decimal, and "," is used to separate latitude and longitude.',
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
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
1070
'#size'=>50,
'#maxlength'=>255,
'#description'=>t('The default longitude, latitude of a Google map.'),
);
$form['defaults']['gmap_default_zoom']=array(
'#type'=>'select',
'#title'=>t('Default zoom'),
'#default_value'=>GMAP_ZOOM,
'#options' => drupal_map_assoc(range(0, 17)),
'#description'=>t('The default zoom level of a Google map.'),
);
$form['defaults']['gmap_default_control']=array(
'#type'=>'select',
'#title'=>t('Default control type'),
'#default_value'=>GMAP_CONTROL,
'#options'=>array('None'=>t('None'),'Small'=>t('Small'),'Large'=>t('Large')),
);
$form['defaults']['gmap_default_type']=array(
'#type'=>'select',
'#title'=>t('Default map type'),
'#default_value'=>GMAP_TYPE,
'#options'=>array('Map'=>t('Map'),'Satellite'=>t('Satellite'),'Hybrid'=>t('Hybrid')),
);
$form['defaults']['gmap_default_line1_color']=array(
'#type'=>'textfield',
'#title'=>t('Default Line 1 Color'),
'#default_value'=>GMAP_LINECOLOR1,
'#size'=>25,
'#maxlength'=>7 ,
);
$form['defaults']['gmap_default_line2_color']=array(
'#type'=>'textfield',
'#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();
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.';" class="gmap-map"></div>'
);
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
$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);'),
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
);
$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',
function gmap_get_markers(){
static $markers='';
if (!is_array($markers)){
$markers=array();
$markerdir=variable_get('gmap_markerfiles',drupal_get_path('module', 'gmap').'/markers');
// Retrieve and sort a list of available markers
$marker_images = file_scan_directory($markerdir, '.*\.png$',array('shadow.png','.','..'),0,true, 'filename');
foreach ($marker_images as $marker) {
preg_match('/markers\/([a-z]*\/*[a-zA-Z_-]+)\d*\.png/',$marker->filename,$matches);
if ($matches) {
//$thisfile=substr($marker->filename,strlen($markerdir)+1,-4);
$markers[$matches[1]] = $matches[1];
}
}
asort($markers);
}
return $markers;
}
/**
* Display the nodes of a view in a Google Map
*/
function theme_views_view_gmap($view, $nodes) {
$fields = _views_get_fields();
$markers = array();
foreach ($nodes as $node) {
$node_data = node_load(array('nid'=>$node->nid));
$location = $node_data->location;
if (($location['lat']) && ($location['lon'])) {
$marker_label = '';
$marker_label .= '<div class="'. $field['field'] .'">'. views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node) .'</div>';
$markers[] = array('markername' => variable_get('gmap_node_marker_'.$node_data->type, ''),
'label' => str_replace("'","\'",$marker_label),
'point' => $location['lat'] . ',' . $location['lon']);
}
}
$thismap = array('id' => 'view_gmap', 'markers' => $markers);
$output .= gmap_draw_map($thismap);
return $output;
}