1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Ivory Google Map package. |
5
|
|
|
* |
6
|
|
|
* (c) Eric GELOEN <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please read the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Ivory\GoogleMap\Control; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @author GeLo <[email protected]> |
16
|
|
|
*/ |
17
|
|
|
class ControlManager |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var FullscreenControl|null |
21
|
|
|
*/ |
22
|
|
|
private $fullscreenControl; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var MapTypeControl|null |
26
|
|
|
*/ |
27
|
|
|
private $mapTypeControl; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var RotateControl|null |
31
|
|
|
*/ |
32
|
|
|
private $rotateControl; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var ScaleControl|null |
36
|
|
|
*/ |
37
|
|
|
private $scaleControl; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var StreetViewControl|null |
41
|
|
|
*/ |
42
|
|
|
private $streetViewControl; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var ZoomControl|null |
46
|
|
|
*/ |
47
|
|
|
private $zoomControl; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var CustomControl[] |
51
|
|
|
*/ |
52
|
|
|
private $customControls = []; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return bool |
56
|
|
|
*/ |
57
|
|
|
public function hasFullscreenControl() |
58
|
|
|
{ |
59
|
|
|
return $this->fullscreenControl !== null; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return FullscreenControl|null |
64
|
|
|
*/ |
65
|
|
|
public function getFullscreenControl() |
66
|
|
|
{ |
67
|
|
|
return $this->fullscreenControl; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param FullscreenControl|null $fullscreenControl |
72
|
|
|
*/ |
73
|
|
|
public function setFullscreenControl(FullscreenControl $fullscreenControl = null) |
74
|
|
|
{ |
75
|
|
|
$this->fullscreenControl = $fullscreenControl; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return bool |
80
|
|
|
*/ |
81
|
|
|
public function hasMapTypeControl() |
82
|
|
|
{ |
83
|
|
|
return $this->mapTypeControl !== null; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return MapTypeControl|null |
88
|
|
|
*/ |
89
|
|
|
public function getMapTypeControl() |
90
|
|
|
{ |
91
|
|
|
return $this->mapTypeControl; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param MapTypeControl|null $mapTypeControl |
96
|
|
|
*/ |
97
|
|
|
public function setMapTypeControl(MapTypeControl $mapTypeControl = null) |
98
|
|
|
{ |
99
|
|
|
$this->mapTypeControl = $mapTypeControl; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return bool |
104
|
|
|
*/ |
105
|
|
|
public function hasRotateControl() |
106
|
|
|
{ |
107
|
|
|
return $this->rotateControl !== null; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @return RotateControl|null |
112
|
|
|
*/ |
113
|
|
|
public function getRotateControl() |
114
|
|
|
{ |
115
|
|
|
return $this->rotateControl; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @param RotateControl|null $rotateControl |
120
|
|
|
*/ |
121
|
|
|
public function setRotateControl(RotateControl $rotateControl = null) |
122
|
|
|
{ |
123
|
|
|
$this->rotateControl = $rotateControl; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @return bool |
128
|
|
|
*/ |
129
|
|
|
public function hasScaleControl() |
130
|
|
|
{ |
131
|
|
|
return $this->scaleControl !== null; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @return ScaleControl|null |
136
|
|
|
*/ |
137
|
|
|
public function getScaleControl() |
138
|
|
|
{ |
139
|
|
|
return $this->scaleControl; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @param ScaleControl|null $scaleControl |
144
|
|
|
*/ |
145
|
|
|
public function setScaleControl(ScaleControl $scaleControl = null) |
146
|
|
|
{ |
147
|
|
|
$this->scaleControl = $scaleControl; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @return bool |
152
|
|
|
*/ |
153
|
|
|
public function hasStreetViewControl() |
154
|
|
|
{ |
155
|
|
|
return $this->streetViewControl !== null; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @return StreetViewControl|null |
160
|
|
|
*/ |
161
|
|
|
public function getStreetViewControl() |
162
|
|
|
{ |
163
|
|
|
return $this->streetViewControl; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @param StreetViewControl|null $streetViewControl |
168
|
|
|
*/ |
169
|
|
|
public function setStreetViewControl(StreetViewControl $streetViewControl = null) |
170
|
|
|
{ |
171
|
|
|
$this->streetViewControl = $streetViewControl; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @return bool |
176
|
|
|
*/ |
177
|
|
|
public function hasZoomControl() |
178
|
|
|
{ |
179
|
|
|
return $this->zoomControl !== null; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* @return ZoomControl|null |
184
|
|
|
*/ |
185
|
|
|
public function getZoomControl() |
186
|
|
|
{ |
187
|
|
|
return $this->zoomControl; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* @param ZoomControl|null $zoomControl |
192
|
|
|
*/ |
193
|
|
|
public function setZoomControl(ZoomControl $zoomControl = null) |
194
|
|
|
{ |
195
|
|
|
$this->zoomControl = $zoomControl; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* @return bool |
200
|
|
|
*/ |
201
|
|
|
public function hasCustomControls() |
202
|
|
|
{ |
203
|
|
|
return !empty($this->customControls); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* @return CustomControl[] |
208
|
|
|
*/ |
209
|
|
|
public function getCustomControls() |
210
|
|
|
{ |
211
|
|
|
return $this->customControls; |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* @param CustomControl[] $customControls |
216
|
|
|
*/ |
217
|
|
|
public function setCustomControls(array $customControls) |
218
|
|
|
{ |
219
|
|
|
$this->customControls = []; |
220
|
|
|
$this->addCustomControls($customControls); |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* @param CustomControl[] $customControls |
225
|
|
|
*/ |
226
|
|
|
public function addCustomControls(array $customControls) |
227
|
|
|
{ |
228
|
|
|
foreach ($customControls as $customControl) { |
229
|
|
|
$this->addCustomControl($customControl); |
230
|
|
|
} |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* @param CustomControl $customControl |
235
|
|
|
* |
236
|
|
|
* @return bool |
237
|
|
|
*/ |
238
|
|
|
public function hasCustomControl(CustomControl $customControl) |
239
|
|
|
{ |
240
|
|
|
return in_array($customControl, $this->customControls, true); |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* @param CustomControl $customControl |
245
|
|
|
*/ |
246
|
|
|
public function addCustomControl(CustomControl $customControl) |
247
|
|
|
{ |
248
|
|
|
if (!$this->hasCustomControl($customControl)) { |
249
|
|
|
$this->customControls[] = $customControl; |
250
|
|
|
} |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* @param CustomControl $customControl |
255
|
|
|
*/ |
256
|
|
|
public function removeCustomControl(CustomControl $customControl) |
257
|
|
|
{ |
258
|
|
|
unset($this->customControls[array_search($customControl, $this->customControls, true)]); |
259
|
|
|
$this->customControls = array_values($this->customControls); |
260
|
|
|
} |
261
|
|
|
} |
262
|
|
|
|