/[drupal]/contributions/modules/gmap/gmap_settings_ui.inc
ViewVC logotype

Contents of /contributions/modules/gmap/gmap_settings_ui.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.12 - (show annotations) (download) (as text)
Thu Feb 12 23:45:23 2009 UTC (9 months, 1 week ago) by bdragon
Branch: MAIN
CVS Tags: DRUPAL-6--1-1-RC1, HEAD
Changes since 1.11: +172 -17 lines
File MIME type: text/x-php
Add support for ClusterMarker and MarkerManager (without the G) marker managers.

Fix #155104 by Scott Falconer: Add "Zoom to cluster area" support.

Allow falling back to the default Clusterer marker if desired.

Allow entering larger numbers in some marker manager settings.

Allow choosing between the original and the new "zoom to marker area" behavior on Clusterer.
1 <?php
2 // $Id: gmap_settings_ui.inc,v 1.11 2009/02/10 16:33:38 bdragon Exp $
3
4 /**
5 * @file
6 * GMap settings form.
7 */
8
9 function gmap_admin_settings(&$form_state) {
10 // Reset the icondata cache.
11 gmap_get_icondata(TRUE);
12
13 //note the same google api key variable name as in the googlemap module is used
14 //note the name of the variable for center of the map is latlong although the format is actually longitude, latitude
15
16 $form['initialization'] = array(
17 '#type' => 'fieldset',
18 '#title' => t('Google Map Initialize'),
19 );
20 if (!module_exists('keys_api')) {
21 $form['initialization']['googlemap_api_key'] = array(
22 '#type' => 'textfield',
23 '#title' => t('Google Maps API Key'),
24 '#default_value' => variable_get('googlemap_api_key', ''),
25 '#size' => 50,
26 '#maxlength' => 255,
27 '#description' => t('Your personal Googlemaps API key. You must get this for each separate website at <a href="http://www.google.com/apis/maps/">Google Map API website</a>.'),
28 );
29 }
30 else {
31 $form['initialization']['googlemap_api_key'] = array(
32 '#type' => 'item',
33 '#title' => t('Google Maps API Key'),
34 '#description' => t('Your personal Googlemaps API key. You must get this for each separate website at <a href="http://www.google.com/apis/maps/">Google Map API website</a>.'),
35 '#value' => t("Managed by <a href='@url'>keys api</a>.", array('@url' => url('admin/settings/keys'))),
36 );
37 }
38
39 if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) != FILE_DOWNLOADS_PUBLIC) {
40 $form['initialization']['gmap_private_markerfile'] = array(
41 '#type' => 'textfield',
42 '#title' => t('Path to gmap_markers.js'),
43 '#description' => t('You are using the <em>Private</em> download method. For markers to work properly. you must press the <em>Regenerate</em> button, manually copy js/gmap_markers.js from the files directory to a location accessible by the webserver, and enter the file path relative to the Drupal root (including the filename) in this field. Example: <em>sites/default/misc/gmap_markers.js</em>'),
44 '#default_value' => variable_get('gmap_private_markerfile', ''),
45 );
46 }
47
48 $form['initialization']['rebuild'] = array(
49 '#type' => 'fieldset',
50 '#title' => t('Regenerate marker cache'),
51 '#description' => t('If you are having problems with markers, or have modified the .ini files in the markers folder, click here to rebuild the marker cache file.'),
52 );
53
54 $form['initialization']['rebuild']['rebuild_marker_js'] = array(
55 '#type' => 'submit',
56 '#value' => t('Regenerate'),
57 '#submit' => array('_gmap_rebuild_marker_js_submit'),
58 );
59
60 $defaults = gmap_defaults();
61
62 $form['gmap_default'] = array(
63 '#type' => 'fieldset',
64 '#title' => t('Default map settings'),
65 // This will store all the defaults in one variable.
66 '#tree' => TRUE,
67 );
68 $form['gmap_default']['map'] = array(
69 '#type' => 'gmap',
70 '#map' => 'settings_default_map',
71 '#settings' => array(
72 'behavior' => array(
73 'nodrag' => FALSE,
74 'nokeyboard' => FALSE,
75 ),
76 ),
77 );
78
79 // Allow previewable behaviors to affect the preview map.
80 $m = array();
81 $behaviors = module_invoke_all('gmap', 'behaviors', $m);
82 foreach ($behaviors as $k => $v) {
83 if (isset($v['previewable']) && $v['previewable']) {
84 $form['gmap_default']['map']['#settings']['behavior'][$k] = $defaults['behavior'][$k];
85 }
86 }
87
88 $form['gmap_default']['width'] = array(
89 '#type' => 'gmap_dimension',
90 '#title' => t('Default width'),
91 '#default_value' => $defaults['width'],
92 '#size' => 25,
93 '#maxlength' => 25,
94 '#description' => t('The default width of a Google map, as a CSS length or percentage. Examples: <em>50px</em>, <em>5em</em>, <em>2.5in</em>, <em>95%</em>'),
95 );
96 gmap_widget_setup($form['gmap_default']['width'], 'width', 'settings_default_map');
97 $form['gmap_default']['height'] = array(
98 '#type' => 'gmap_dimension',
99 '#title' => t('Default height'),
100 '#default_value' => $defaults['height'],
101 '#size' => 25,
102 '#maxlength' => 25,
103 '#description' => t('The default height of a Google map, as a CSS length or percentage. Examples: <em>50px</em>, <em>5em</em>, <em>2.5in</em>, <em>95%</em>'),
104 );
105 gmap_widget_setup($form['gmap_default']['height'], 'height', 'settings_default_map');
106 $form['gmap_default']['latlong'] = array(
107 '#type' => 'gmap_latlon',
108 '#map' => 'settings_default_map',
109 '#title' => t('Default center'),
110 '#default_value' => $defaults['latlong'],
111 '#size' => 50,
112 '#maxlength' => 255,
113 '#description' => t('The default center coordinates of Google map, expressed as a decimal latitude and longitude, separated by a comma.'),
114 );
115 $form['gmap_default']['zoom'] = array(
116 '#type' => 'select',
117 '#title' => t('Default zoom'),
118 '#default_value' => $defaults['zoom'],
119 '#options' => drupal_map_assoc(range(0, 17)),
120 '#description' => t('The default zoom level of a Google map.'),
121 );
122 gmap_widget_setup($form['gmap_default']['zoom'], 'zoom', 'settings_default_map');
123 $form['gmap_default']['maxzoom'] = array(
124 '#type' => 'select',
125 '#title' => t('Maximum initial zoom'),
126 '#default_value' => $defaults['maxzoom'],
127 '#options' => drupal_map_assoc(range(0, 17)),
128 '#description' => t('The maximum initial zoom (affects things such as the zoom of the node location block.)'),
129 );
130 // This one isn't a gmap widget.
131
132 $form['gmap_default']['styles']['line_default'] = array(
133 '#type' => 'gmap_style',
134 '#gmap_style_type' => 'line',
135 '#title' => t('Line default style'),
136 '#description' => t('Lines without a specific style defined will fall back to this style'),
137 '#default_value' => $defaults['styles']['line_default'],
138 );
139 $form['gmap_default']['styles']['poly_default'] = array(
140 '#type' => 'gmap_style',
141 '#gmap_style_type' => 'poly',
142 '#title' => t('Polygon default style'),
143 '#description' => t('Polygons without a specific style defined will fall back to this style'),
144 '#default_value' => $defaults['styles']['poly_default'],
145 );
146
147 $form['gmap_default']['controltype'] = array(
148 '#type' => 'select',
149 '#title' => t('Default control type'),
150 '#options' => array('None' => t('None'), 'Micro' => t('Micro'), 'Small' => t('Small'), 'Large' => t('Large')),
151 '#default_value' => $defaults['controltype'],
152 );
153 gmap_widget_setup($form['gmap_default']['controltype'], 'controltype', 'settings_default_map');
154
155 $form['gmap_default']['mtc'] = array(
156 '#type' => 'select',
157 '#title' => t('Map Type Control'),
158 '#options' => array(
159 'none' => t('None'),
160 'standard' => t('Standard (GMapTypeControl)'),
161 'hier' => t('Hierarchical (GHierarchicalMapTypeControl)'),
162 'menu' => t('Dropdown (GMenuMapTypeControl)'),
163 ),
164 '#default_value' => $defaults['mtc'],
165 );
166
167 $form['gmap_default']['baselayers'] = array(
168 '#type' => 'fieldset',
169 '#title' => t('Enabled map types ("base layers")'),
170 );
171
172 $baselayers = array();
173
174 foreach (module_implements('gmap') as $module) {
175 call_user_func_array($module .'_gmap', array('baselayers', &$baselayers));
176 }
177
178 $options = array();
179 foreach ($baselayers as $name => $layers) {
180 $options[$name] = array();
181 foreach ($layers as $k => $v) {
182 // @@@TODO: Only show the enabled ones?
183 $options[$name][$k] = $v['title'];
184 }
185 }
186
187 $form['gmap_default']['baselayers']['maptype'] = array(
188 '#type' => 'select',
189 '#tree' => FALSE,
190 '#parents' => array('gmap_default', 'maptype'),
191 '#title' => t('Default map type'),
192 '#default_value' => $defaults['maptype'],
193 '#options' => $options,
194 );
195 gmap_widget_setup($form['gmap_default']['baselayers']['maptype'], 'maptype', 'settings_default_map');
196
197 foreach ($baselayers as $name => $layers) {
198 $form['gmap_default']['baselayers'][$name] = array(
199 '#type' => 'fieldset',
200 '#title' => $name,
201 );
202 foreach ($layers as $key => $layer) {
203 $form['gmap_default']['baselayers'][$name][$key] = array(
204 '#type' => 'checkbox',
205 '#title' => $layer['title'],
206 '#parents' => array('gmap_default', 'baselayers', $key),
207
208 '#description' => $layer['help'],
209 '#default_value' => isset($defaults['baselayers'][$key]) ? $defaults['baselayers'][$key] : $layer['default'],
210 );
211 }
212 }
213
214 $form['gmap_default']['behavior'] = array(
215 '#type' => 'fieldset',
216 '#title' => t('Map Behavior flags'),
217 '#tree' => TRUE,
218 '#description' => t('Behavior flags modify how a map behaves. Grayed out flags are not settable here, but may be set on a map by map basis via code or a macro. Changes to behaviors will not affect the preview map shown above until changes are saved.'),
219 );
220 $m = array();
221 $behaviors = module_invoke_all('gmap', 'behaviors', $m);
222 foreach ($behaviors as $k => $v) {
223 $form['gmap_default']['behavior'][$k] = array(
224 '#type' => 'checkbox',
225 '#title' => t('@name : @title', array('@name' => $k, '@title' => $v['title'])),
226 '#default_value' => isset($defaults['behavior'][$k]) ? $defaults['behavior'][$k] : $v['default'],
227 '#description' => isset($v['help']) ? $v['help'] : '',
228 );
229 if (isset($v['internal']) && $v['internal']) {
230 $form['gmap_default']['behavior'][$k]['#disabled'] = TRUE;
231 // Compensate for behaviors becoming internal after acquiring the wrong value.
232 $form['gmap_default']['behavior'][$k]['#value'] = $v['default'];
233 }
234 }
235
236 $form['gmap_default']['markermode'] = array(
237 '#type' => 'radios',
238 '#title' => t('Marker action'),
239 '#description' => t('Perform this action when a marker is clicked.'),
240 '#options' => array(t('Do nothing'), t('Open info window'), t('Open link')),
241 '#default_value' => isset($defaults['markermode']) ? $defaults['markermode'] : 0,
242 );
243
244 $form['gmap_default']['line_colors'] = array(
245 '#tree' => TRUE,
246 );
247 $form['gmap_default']['line_colors'][0] = array(
248 '#type' => 'textfield',
249 '#title' => t('Default Line 1 Color'),
250 '#default_value' => $defaults['line_colors'][0],
251 '#size' => 12,
252 '#maxlength' => 7,
253 );
254 $form['gmap_default']['line_colors'][1] = array(
255 '#type' => 'textfield',
256 '#title' => t('Default Line 2 Color'),
257 '#default_value' => $defaults['line_colors'][1],
258 '#size' => 12,
259 '#maxlength' => 7,
260 );
261 $form['gmap_default']['line_colors'][2] = array(
262 '#type' => 'textfield',
263 '#title' => t('Default Line 3 Color'),
264 '#default_value' => $defaults['line_colors'][2],
265 '#size' => 12,
266 '#maxlength' => 7,
267 );
268
269 $opts = variable_get('gmap_markermanager', array());
270 if (!isset($opts['gmap']) || !is_array($opts['gmap'])) {
271 $opts['gmap'] = array();
272 }
273 if (!isset($opts['gmarkermanager']) || !is_array($opts['gmarkermanager'])) {
274 $opts['gmarkermanager'] = array();
275 }
276 if (!isset($opts['markermanager']) || !is_array($opts['markermanager'])) {
277 $opts['markermanager'] = array();
278 }
279 if (!isset($opts['clusterer']) || !is_array($opts['clusterer'])) {
280 $opts['clusterer'] = array();
281 }
282 if (!isset($opts['clustermarker']) || !is_array($opts['clustermarker'])) {
283 $opts['clustermarker'] = array();
284 }
285
286 $opts['gmap'] = array_merge(array(
287 // None.
288 ), $opts['gmap']);
289
290 $opts['gmarkermanager'] = array_merge(array(
291 'borderPadding' => 256,
292 'maxZoom' => 4,
293 'trackMarkers' => FALSE,
294 'markerMinZoom' => 4,
295 'markerMaxZoom' => 0,
296 ), $opts['gmarkermanager']);
297
298 $opts['markermanager'] = array_merge(array(
299 'filename' => 'markermanager_packed.js',
300 'borderPadding' => 256,
301 'maxZoom' => 4,
302 'trackMarkers' => FALSE,
303 'markerMinZoom' => 4,
304 'markerMaxZoom' => 0,
305 ), $opts['markermanager']);
306
307 $opts['clusterer'] = array_merge(array(
308 'filename' => 'Clusterer2.js',
309 'marker' => 'cluster',
310 'max_nocluster' => 150,
311 'cluster_min' => 5,
312 'max_lines' => 10,
313 'popup_mode' => 'orig',
314 ), $opts['clusterer']);
315
316 $opts['clustermarker'] = array_merge(array(
317 'filename' => 'ClusterMarker.js',
318 'borderPadding' => 256,
319 'clusteringEnabled' => TRUE,
320 'clusterMarkerIcon' => '',
321 'clusterMarkerTitle' => '',
322 'fitMapMaxZoom' => 0,
323 'intersectPadding' => 0,
324 ), $opts['clustermarker']);
325
326 $form['gmap_markermanager'] = array(
327 '#type' => 'fieldset',
328 '#title' => t('Marker manager'),
329 '#tree' => TRUE,
330 );
331 $form['gmap_markermanager']['gmap_mm_type'] = array(
332 '#type' => 'radios',
333 '#tree' => FALSE,
334 '#required' => TRUE,
335 '#options' => array(
336 'gmap' => t('No manager (use GMap API directly)'),
337 'gmarkermanager' => t("Google's GMarkerManager"),
338 'markermanager' => t('Gmaps Utility Library MarkerManager'),
339 'clusterer' => t("Jef Poskanzer's Clusterer"),
340 'clustermarker' => t("Martin Pearman's ClusterMarker"),
341 ),
342 '#default_value' => variable_get('gmap_mm_type', 'gmap'),
343 '#description' => t('If you are planning on using many markers on a single map, you may want to consider using a marker manager to speed up map rendering.'),
344 );
345
346 // No Manager
347 $form['gmap_markermanager']['gmap'] = array(
348 '#type' => 'fieldset',
349 '#title' => t('Unmanaged marker settings'),
350 '#description' => t('There are no settings for unmanaged markers.'),
351 '#collapsible' => TRUE,
352 '#collapsed' => TRUE,
353 );
354
355 // Google Maps API GMarkerManager
356 $form['gmap_markermanager']['gmarkermanager'] = array(
357 '#type' => 'fieldset',
358 '#title' => t('GMarkerManager settings'),
359 '#description' => t('GMarkerManager is a new part of the official Google Maps API that provides a marker manager.'),
360 '#collapsible' => TRUE,
361 '#collapsed' => TRUE,
362 );
363 $form['gmap_markermanager']['gmarkermanager']['borderPadding'] = array(
364 '#type' => 'textfield',
365 '#title' => t('Border padding'),
366 '#description' => t('Markers located less than this number of pixels from the viewport will be added to the map by the manager (even if they would be fully invisible.)'),
367 '#size' => 4,
368 '#maxlength' => 4,
369 '#default_value' => $opts['gmarkermanager']['borderPadding'],
370 );
371 $form['gmap_markermanager']['gmarkermanager']['maxZoom'] = array(
372 '#type' => 'select',
373 '#title' => t('Maximum zoom'),
374 '#options' => drupal_map_assoc(range(0, 17)),
375 '#description' => t('At the specified zoom level and above, the marker manager will disable itself for additional speed.'),
376 '#default_value' => $opts['gmarkermanager']['maxZoom'],
377 );
378 $form['gmap_markermanager']['gmarkermanager']['trackMarkers'] = array(
379 '#type' => 'checkbox',
380 '#title' => t('Track markers'),
381 '#description' => t('If enabled, the marker manager will track marker movements. Leave off unless you need to move markers around with setPoint.'),
382 '#default_value' => $opts['gmarkermanager']['trackMarkers'],
383 );
384 $form['gmap_markermanager']['gmarkermanager']['defaults'] = array(
385 '#type' => 'fieldset',
386 '#title' => t('Marker defaults'),
387 '#description' => t('Default marker-specific settings for GMarkerManager. Markers will appear when the current zoom level is between minZoom and maxZoom.'),
388 );
389 $form['gmap_markermanager']['gmarkermanager']['defaults']['markerMinZoom'] = array(
390 '#type' => 'select',
391 '#title' => t('Minimum zoom'),
392 '#options' => drupal_map_assoc(range(0, 17)),
393 '#description' => t('At the specified zoom level and above (i.e. zooming in,) the marker will be shown. Choose 0 to show markers at all zoom levels by default.'),
394 '#default_value' => $opts['gmarkermanager']['markerMinZoom'],
395 '#parents' => array('gmap_markermanager', 'gmarkermanager', 'markerMinZoom'),
396 );
397 $form['gmap_markermanager']['gmarkermanager']['defaults']['markerMaxZoom'] = array(
398 '#type' => 'select',
399 '#title' => t('Maximum zoom'),
400 '#options' => drupal_map_assoc(range(0, 17)),
401 '#description' => t('At the specified zoom level and above (i.e. zooming in,) the marker will be hidden. Choose 0 to disable by default.'),
402 '#default_value' => $opts['gmarkermanager']['markerMaxZoom'],
403 '#parents' => array('gmap_markermanager', 'gmarkermanager', 'markerMaxZoom'),
404 );
405
406 // Gmaps Utility Library -- MarkerManager
407 $form['gmap_markermanager']['markermanager'] = array(
408 '#type' => 'fieldset',
409 '#title' => t('MarkerManager settings'),
410 '#description' => t('MarkerManager is the improved open source version of GMarkerManager. To use, you must download it from <a href="@url">here</a> and place it in the <em>thirdparty</em> folder.', array('@url' => 'http://gmaps-utility-library.googlecode.com/svn/trunk/markermanager/release/src/')),
411 '#collapsible' => TRUE,
412 '#collapsed' => TRUE,
413 );
414 $form['gmap_markermanager']['markermanager']['filename'] = array(
415 '#type' => 'textfield',
416 '#title' => t('Filename'),
417 '#description' => t('Name of downloaded file in the thirdparty folder. Default: %default', array('%default' => 'markermanager_packed.js')),
418 '#default_value' => $opts['markermanager']['filename'],
419 );
420 $form['gmap_markermanager']['markermanager']['borderPadding'] = array(
421 '#type' => 'textfield',
422 '#title' => t('Border padding'),
423 '#description' => t('Markers located less than this number of pixels from the viewport will be added to the map by the manager (even if they would be fully invisible.)'),
424 '#size' => 4,
425 '#maxlength' => 4,
426 '#default_value' => $opts['markermanager']['borderPadding'],
427 );
428 $form['gmap_markermanager']['markermanager']['maxZoom'] = array(
429 '#type' => 'select',
430 '#title' => t('Maximum zoom'),
431 '#options' => drupal_map_assoc(range(0, 17)),
432 '#description' => t('At the specified zoom level and above, the marker manager will disable itself for additional speed.'),
433 '#default_value' => $opts['markermanager']['maxZoom'],
434 );
435 $form['gmap_markermanager']['markermanager']['trackMarkers'] = array(
436 '#type' => 'checkbox',
437 '#title' => t('Track markers'),
438 '#description' => t('If enabled, the marker manager will track marker movements. Leave off unless you need to move markers around with setPoint.'),
439 '#default_value' => $opts['markermanager']['trackMarkers'],
440 );
441 $form['gmap_markermanager']['markermanager']['defaults'] = array(
442 '#type' => 'fieldset',
443 '#title' => t('Marker defaults'),
444 '#description' => t('Default marker-specific settings for MarkerManager. Markers will appear when the current zoom level is between minZoom and maxZoom.'),
445 );
446 $form['gmap_markermanager']['markermanager']['defaults']['markerMinZoom'] = array(
447 '#type' => 'select',
448 '#title' => t('Minimum zoom'),
449 '#options' => drupal_map_assoc(range(0, 17)),
450 '#description' => t('At the specified zoom level and above (i.e. zooming in,) the marker will be shown. Choose 0 to show markers at all zoom levels by default.'),
451 '#default_value' => $opts['markermanager']['markerMinZoom'],
452 '#parents' => array('gmap_markermanager', 'markermanager', 'markerMinZoom'),
453 );
454
455 $form['gmap_markermanager']['markermanager']['defaults']['markerMaxZoom'] = array(
456 '#type' => 'select',
457 '#title' => t('Maximum zoom'),
458 '#options' => drupal_map_assoc(range(0, 17)),
459 '#description' => t('At the specified zoom level and above (i.e. zooming in,) the marker will be hidden. Choose 0 to disable by default.'),
460 '#default_value' => $opts['markermanager']['markerMaxZoom'],
461 '#parents' => array('gmap_markermanager', 'markermanager', 'markerMaxZoom'),
462 );
463
464 // Jef Poskanzer's Clusterer
465 $form['gmap_markermanager']['clusterer'] = array(
466 '#type' => 'fieldset',
467 '#title' => t('Clusterer settings'),
468 '#description' => t("Clusterer is a marker manager written by Jef Poskanzer of acme.com. To use, you must place Clusterer2.js (available ".'<a href="@url">here</a>) into the "thirdparty" folder.', array('@url' => 'http://acme.com/javascript/Clusterer2.js')),
469 '#collapsible' => TRUE,
470 '#collapsed' => TRUE,
471 );
472 $form['gmap_markermanager']['clusterer']['filename'] = array(
473 '#type' => 'textfield',
474 '#title' => t('Filename'),
475 '#description' => t('Name of downloaded file in the thirdparty folder. Default: %default', array('%default' => 'Clusterer2.js')),
476 '#default_value' => $opts['clusterer']['filename'],
477 );
478 $form['gmap_markermanager']['clusterer']['marker'] = array(
479 '#type' => 'gmap_markerchooser',
480 '#title' => t('Marker for clusters'),
481 '#description' => t('The marker to use when creating a cluster.'),
482 '#default_value' => $opts['clusterer']['marker'],
483 );
484 $form['gmap_markermanager']['clusterer']['max_nocluster'] = array(
485 '#type' => 'textfield',
486 '#title' => t('Activate on'),
487 '#field_suffix' => t('or more markers'),
488 '#description' => t("Clustering is enabled when more than the specified number of markers are visible at the same time."),
489 '#size' => 4,
490 '#maxlength' => 4,
491 '#default_value' => $opts['clusterer']['max_nocluster'],
492 );
493 $form['gmap_markermanager']['clusterer']['cluster_min'] = array(
494 '#type' => 'textfield',
495 '#title' => t('Cluster on'),
496 '#field_suffix' => t('or more markers'),
497 '#description' => t("Minimal number of markers per cluster"),
498 '#size' => 3,
499 '#maxlength' => 3,
500 '#default_value' => $opts['clusterer']['cluster_min'],
501 );
502 $form['gmap_markermanager']['clusterer']['max_lines'] = array(
503 '#type' => 'textfield',
504 '#title' => t('Lines per box'),
505 '#field_prefix' => t('at most'),
506 '#field_suffix' => t('lines'),
507 '#description' => t("Maximum number of lines per info box"),
508 '#size' => 3,
509 '#maxlength' => 3,
510 '#default_value' => $opts['clusterer']['max_lines'],
511 );
512 $form['gmap_markermanager']['clusterer']['popup_mode'] = array(
513 '#type' => 'radios',
514 '#title' => t('Popup mode'),
515 '#options' => array('orig' => t('Original'), 'zoom' => t('Zoom to Cluster')),
516 '#default_value' => $opts['clusterer']['popup_mode'],
517 );
518
519 // Martin Pearman's ClusterMarker
520 $form['gmap_markermanager']['clustermarker'] = array(
521 '#type' => 'fieldset',
522 '#title' => t('ClusterMarker settings'),
523 '#description' => t('ClusterMarker is a marker manager written by Martin Pearman. To use, you must download it from <a href="@url">here</a> and extract the appropriate file to the <em>thirdparty</em> folder.', array('@url' => 'http://googlemapsapi.martinpearman.co.uk/downloads.php?cat_id=1')),
524 '#collapsible' => TRUE,
525 '#collapsed' => TRUE,
526 );
527 $form['gmap_markermanager']['clustermarker']['filename'] = array(
528 '#type' => 'textfield',
529 '#title' => t('Filename'),
530 '#description' => t('Name of downloaded file in the thirdparty folder. Default: %default', array('%default' => 'ClusterMarker.js')),
531 '#default_value' => $opts['clustermarker']['filename'],
532 );
533 $form['gmap_markermanager']['clustermarker']['borderPadding'] = array(
534 '#type' => 'textfield',
535 '#title' => t('Border padding'),
536 '#description' => t('Markers located less than this number of pixels from the viewport will be added to the map by the manager (even if they would be fully invisible.)'),
537 '#size' => 4,
538 '#maxlength' => 4,
539 '#default_value' => $opts['clustermarker']['borderPadding'],
540 );
541 $form['gmap_markermanager']['clustermarker']['clusteringEnabled'] = array(
542 '#type' => 'checkbox',
543 '#title' => t('Clustering enabled'),
544 '#description' => t('Whether to use clustering or not.'),
545 '#default_value' => $opts['clustermarker']['clusteringEnabled'],
546 );
547 $form['gmap_markermanager']['clustermarker']['clusterMarkerIcon'] = array(
548 '#type' => 'gmap_markerchooser',
549 '#title' => t('Marker for clusters'),
550 '#description' => t('The marker to use when creating a cluster.'),
551 '#default_value' => $opts['clustermarker']['clusterMarkerIcon'],
552 );
553 $form['gmap_markermanager']['clustermarker']['clusterMarkerTitle'] = array(
554 '#type' => 'textfield',
555 '#title' => t('Title for clusters'),
556 '#description' => t("The title to use for clusters. %count will be replaced with the number of markers in the cluster."),
557 '#default_value' => $opts['clustermarker']['clusterMarkerTitle'],
558 );
559 $form['gmap_markermanager']['clustermarker']['fitMapMaxZoom'] = array(
560 '#type' => 'select',
561 '#title' => t('Maximum zoom for zooming to cluster'),
562 '#options' => drupal_map_assoc(range(0, 17)),
563 '#description' => t('When clicking on a cluster, the map will not zoom in farther than this.'),
564 '#default_value' => $opts['clustermarker']['fitMapMaxZoom'],
565 );
566 $form['gmap_markermanager']['clustermarker']['intersectPadding'] = array(
567 '#type' => 'textfield',
568 '#title' => t('Intersect Padding'),
569 '#description' => t('Number of pixels to pad marker icons by when determining whether they intersect.'),
570 '#default_value' => $opts['clustermarker']['intersectPadding'],
571 '#size' => 4,
572 '#maxlength' => 4,
573 );
574
575 // @@@ Convert to element level validation.
576 $form['#validate'][] = 'gmap_admin_settings_validate';
577
578 return system_settings_form($form);
579 }
580
581 function gmap_admin_settings_validate($form, &$form_state) {
582 $found = FALSE;
583 foreach ($form_state['values']['gmap_default']['baselayers'] as $l) {
584 if ($l) {
585 $found = TRUE;
586 break;
587 }
588 }
589 if (!$found) {
590 form_set_error('gmap_default][baselayers', t('You must select at least one baselayer!'));
591 }
592
593 // Check that the default map type is sane.
594 if (!$form_state['values']['gmap_default']['baselayers'][$form_state['values']['gmap_default']['maptype']]) {
595 form_error($form['gmap_default']['baselayers']['maptype'], t('The default map type must be an enabled baselayer!'));
596 }
597 }
598
599 /**
600 * Rebuild marker js.
601 */
602 function _gmap_rebuild_marker_js_submit($form, &$form_state) {
603 gmap_regenerate_markers();
604 drupal_set_message(t('Marker cache regenerated.'));
605 }

  ViewVC Help
Powered by ViewVC 1.1.2