Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
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
$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();
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
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);'),
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
);
$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();
foreach ($nodes as $node) {
$node_data = node_load(array("nid"=>$node->nid));
$location = $node_data->location;
if (strlen($location['lat'])>0 && strlen($location['lon']>0)) {
$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;