|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Class holding information and functionality specific to OpenLayers. |
|
5
|
|
|
* This information and features can be used by any mapping feature. |
|
6
|
|
|
* |
|
7
|
|
|
* @since 0.1 |
|
8
|
|
|
* |
|
9
|
|
|
* @licence GNU GPL v2+ |
|
10
|
|
|
* @author Jeroen De Dauw < [email protected] > |
|
11
|
|
|
*/ |
|
12
|
|
|
class MapsOpenLayers extends MapsMappingService { |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Constructor. |
|
16
|
|
|
* |
|
17
|
|
|
* @since 0.6.6 |
|
18
|
|
|
*/ |
|
19
|
|
|
public function __construct( $serviceName ) { |
|
20
|
|
|
parent::__construct( |
|
21
|
|
|
$serviceName, |
|
22
|
|
|
[ 'layers', 'openlayer' ] |
|
23
|
|
|
); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @see MapsMappingService::addParameterInfo |
|
28
|
|
|
* |
|
29
|
|
|
* @since 0.7 |
|
30
|
|
|
*/ |
|
31
|
|
|
public function addParameterInfo( array &$params ) { |
|
32
|
|
|
global $egMapsOLLayers, $egMapsOLControls, $egMapsResizableByDefault; |
|
33
|
|
|
|
|
34
|
|
|
$params['zoom'] = [ |
|
35
|
|
|
'type' => 'integer', |
|
36
|
|
|
'range' => [ 0, 19 ], |
|
37
|
|
|
'default' => self::getDefaultZoom(), |
|
38
|
|
|
'message' => 'maps-par-zoom', |
|
39
|
|
|
]; |
|
40
|
|
|
|
|
41
|
|
|
$params['controls'] = [ |
|
42
|
|
|
'default' => $egMapsOLControls, |
|
43
|
|
|
'values' => self::getControlNames(), |
|
44
|
|
|
'message' =>'maps-openlayers-par-controls', |
|
45
|
|
|
'islist' => true, |
|
46
|
|
|
'tolower' => true, |
|
47
|
|
|
]; |
|
48
|
|
|
|
|
49
|
|
|
$params['layers'] = [ |
|
50
|
|
|
'default' => $egMapsOLLayers, |
|
51
|
|
|
'message' =>'maps-openlayers-par-layers', |
|
52
|
|
|
'manipulatedefault' => true, |
|
53
|
|
|
'islist' => true, |
|
54
|
|
|
'tolower' => true, |
|
55
|
|
|
// TODO-customMaps: addCriteria( new CriterionOLLayer() ); |
|
56
|
|
|
]; |
|
57
|
|
|
|
|
58
|
|
|
$params['resizable'] = [ |
|
59
|
|
|
'type' => 'boolean', |
|
60
|
|
|
'default' => false, |
|
61
|
|
|
'manipulatedefault' => false, |
|
62
|
|
|
'message' => 'maps-par-resizable', |
|
63
|
|
|
]; |
|
64
|
|
|
|
|
65
|
|
|
$params['overlays'] = [ |
|
66
|
|
|
// Default empty array will end up in JS just right without manipulation. |
|
67
|
|
|
'default' => [], |
|
68
|
|
|
'manipulatedefault' => false, |
|
69
|
|
|
'message' => 'maps-openlayers-par-overlays', |
|
70
|
|
|
|
|
71
|
|
|
// NOTE: code has moved into @see MapsDisplayMapRenderer |
|
72
|
|
|
// TODO-customMaps: addCriteria( new CriterionOLLayer( ';' ) ); |
|
73
|
|
|
// TODO-customMaps: addManipulations( new MapsParamOLLayers() ); |
|
74
|
|
|
]; |
|
75
|
|
|
|
|
76
|
|
|
$params['resizable'] = [ |
|
77
|
|
|
'type' => 'boolean', |
|
78
|
|
|
'default' => $egMapsResizableByDefault, |
|
79
|
|
|
'message' => 'maps-par-resizable', |
|
80
|
|
|
]; |
|
81
|
|
|
|
|
82
|
|
|
$params['searchmarkers'] = [ |
|
83
|
|
|
'default' => '', |
|
84
|
|
|
'message' => 'maps-par-searchmarkers', |
|
85
|
|
|
'values' => [ 'title', 'all', '' ], |
|
86
|
|
|
'tolower' => true, |
|
87
|
|
|
]; |
|
88
|
|
|
|
|
89
|
|
|
$params['kml'] = [ |
|
90
|
|
|
'default' => [], |
|
91
|
|
|
'message' => 'maps-par-kml', |
|
92
|
|
|
'islist' => true, |
|
93
|
|
|
// new MapsParamFile() FIXME |
|
94
|
|
|
]; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @see iMappingService::getDefaultZoom |
|
99
|
|
|
* |
|
100
|
|
|
* @since 0.6.5 |
|
101
|
|
|
*/ |
|
102
|
|
|
public function getDefaultZoom() { |
|
103
|
|
|
global $egMapsOpenLayersZoom; |
|
104
|
|
|
return $egMapsOpenLayersZoom; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @see MapsMappingService::getMapId |
|
109
|
|
|
* |
|
110
|
|
|
* @since 0.6.5 |
|
111
|
|
|
*/ |
|
112
|
|
|
public function getMapId( $increment = true ) { |
|
113
|
|
|
static $mapsOnThisPage = 0; |
|
114
|
|
|
|
|
115
|
|
|
if ( $increment ) { |
|
116
|
|
|
$mapsOnThisPage++; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
return 'open_layer_' . $mapsOnThisPage; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* Returns the names of all supported controls. |
|
124
|
|
|
* This data is a copy of the one used to actually translate the names |
|
125
|
|
|
* into the controls, since this resides client side, in OpenLayerFunctions.js. |
|
126
|
|
|
* |
|
127
|
|
|
* @return array |
|
128
|
|
|
*/ |
|
129
|
|
|
public static function getControlNames() { |
|
130
|
|
|
return [ |
|
131
|
|
|
'argparser', 'attribution', 'button', 'dragfeature', 'dragpan', |
|
132
|
|
|
'drawfeature', 'editingtoolbar', 'getfeature', 'keyboarddefaults', 'layerswitcher', |
|
133
|
|
|
'measure', 'modifyfeature', 'mousedefaults', 'mouseposition', 'mousetoolbar', |
|
134
|
|
|
'navigation', 'navigationhistory', 'navtoolbar', 'overviewmap', 'pan', |
|
135
|
|
|
'panel', 'panpanel', 'panzoom', 'panzoombar', 'autopanzoom', 'permalink', |
|
136
|
|
|
'scale', 'scaleline', 'selectfeature', 'snapping', 'split', |
|
137
|
|
|
'wmsgetfeatureinfo', 'zoombox', 'zoomin', 'zoomout', 'zoompanel', |
|
138
|
|
|
'zoomtomaxextent' |
|
139
|
|
|
]; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* Returns the names of all supported dynamic layers. |
|
144
|
|
|
* |
|
145
|
|
|
* @param boolean $includeGroups |
|
146
|
|
|
* |
|
147
|
|
|
* @return array |
|
148
|
|
|
*/ |
|
149
|
|
|
public static function getLayerNames( $includeGroups = false ) { |
|
150
|
|
|
global $egMapsOLAvailableLayers, $egMapsOLLayerGroups; |
|
151
|
|
|
|
|
152
|
|
|
$keys = array_keys( $egMapsOLAvailableLayers ); |
|
153
|
|
|
|
|
154
|
|
|
if ( $includeGroups ) { |
|
155
|
|
|
$keys = array_merge( $keys, array_keys( $egMapsOLLayerGroups ) ); |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
return $keys; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* @see MapsMappingService::getResourceModules |
|
163
|
|
|
* |
|
164
|
|
|
* @since 0.7.3 |
|
165
|
|
|
* |
|
166
|
|
|
* @return array of string |
|
167
|
|
|
*/ |
|
168
|
|
|
public function getResourceModules() { |
|
169
|
|
|
return array_merge( |
|
170
|
|
|
parent::getResourceModules(), |
|
171
|
|
|
[ 'ext.maps.openlayers' ] |
|
172
|
|
|
); |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
/** |
|
176
|
|
|
* Returns a list of all config variables that should be passed to the JS. |
|
177
|
|
|
* |
|
178
|
|
|
* @since 1.0.1 |
|
179
|
|
|
* |
|
180
|
|
|
* @return array |
|
181
|
|
|
*/ |
|
182
|
|
|
public function getConfigVariables() { |
|
|
|
|
|
|
183
|
|
|
return array_merge( |
|
184
|
|
|
parent::getConfigVariables(), |
|
185
|
|
|
[ 'egMapsScriptPath' => $GLOBALS['wgScriptPath'] . '/extensions/Maps/' ] |
|
186
|
|
|
); |
|
187
|
|
|
} |
|
188
|
|
|
|
|
189
|
|
|
} |
|
190
|
|
|
|
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: