-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathopendata.preset.inc
executable file
·120 lines (111 loc) · 3.14 KB
/
opendata.preset.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
/**
* Implementation of hook_form_submit()
*
* openlayers_preset_save takes a $style array
* it is located on line 1095 of openlayers.module file
*
* A clone of hook_openlayers_presets()
similar code in openlayers/modules/openlayers_ui/includes/openlayers_ui.presets.inc
on line 464
*/
function opendata_create_preset($preset_name, $preset_type) {
// make sure preset name is alpha-numeric
$pname = strtolower($preset_name);
$pname = str_replace(' ', '_', $pname);
// save the original pname for use with layers below
$layername = $pname;
if ($preset_type == 'detail') {
$pname = $pname . '_detail';
}
// get the map data array
$map = _opendata_build_map($pname, $preset_type, $layername);
$preset = new stdClass();
$preset->disabled = FALSE;
$preset->api_version = 1;
$preset->name = $pname;
$preset->title = $pname;
$preset->description = "A preset created by OpenData module.";
$preset->data = $map;
$result = openlayers_preset_save($preset);
if ($result) {
//drupal_set_message(t('Map saved.'));
return true;
} else {
drupal_set_message(t('Error: could not save OL preset !pname.', array('!pname' => $pname)), 'error');
return false;
}
}
function _opendata_build_map($pname, $preset_type, $layername) {
if ($preset_type == 'detail') {
$height = '200px';
//$centerpoint = '-96.767578121148, 37.926867600188';
$centerpoint = '-101.07421874601, 39.368279147837';
$zoom = '3';
$dot_style = 'dped_blue_large';
$point_zoom_level = '3';
$layer = $layername . '_openlayers_2';
$fullscreen = '';
} else {
$height = '500px';
$centerpoint = '-101.07421874601, 39.368279147837';
$zoom = '2';
$dot_style = 'dped_blue';
$point_zoom_level = '5';
$layer = $layername . '_openlayers_1';
$fullscreen = array();
}
$map = array(
'width' => 'auto',
'height' => $height,
'image_path' => 'profiles/ngp_deped/openlayers/dark/',
'css_path' => '',
'proxy_host' => '',
'center' => array(
'initial' => array(
'centerpoint' => $centerpoint,
'zoom' => $zoom,
),
'restrict' => array(
'restrictextent' => 0,
'restrictedExtent' => '',
),
),
'behaviors' => array(
'openlayers_behavior_attribution' => array(),
'openlayers_behavior_popup' => array(),
//'openlayers_behavior_fullscreen' => $fullscreen,
'openlayers_behavior_fullscreen' => array(),
'openlayers_behavior_keyboarddefaults' => array(),
'openlayers_behavior_navigation' => array(
'zoomWheelEnabled' => 1,
),
'openlayers_behavior_panzoombar' => array(),
'openlayers_behavior_zoomtolayer' => array(
'zoomtolayer' => $layer,
'point_zoom_level' => $point_zoom_level,
),
),
'default_layer' => 'dped_browser_world_light_usa',
'layers' => array(
'dped_browser_world_light_usa' => 'dped_browser_world_light_usa',
$layer => $layer,
),
'layer_styles' => array(
$layer => 'dped_blue',
),
'layer_activated' => array(
$layer => $layer,
),
'layer_switcher' => array(),
'projection' => '900913',
'displayProjection' => '4326',
'styles' => array(
'default' => $dot_style,
'select' => $dot_style,
'temporary' => $dot_style,
),
'options' => NULL,
);
return $map;
}