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 MapTypeControl|null |
21
|
|
|
*/ |
22
|
|
|
private $mapTypeControl; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var RotateControl|null |
26
|
|
|
*/ |
27
|
|
|
private $rotateControl; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var ScaleControl|null |
31
|
|
|
*/ |
32
|
|
|
private $scaleControl; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var StreetViewControl|null |
36
|
|
|
*/ |
37
|
|
|
private $streetViewControl; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var ZoomControl|null |
41
|
|
|
*/ |
42
|
|
|
private $zoomControl; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var CustomControl[] |
46
|
|
|
*/ |
47
|
|
|
private $customControls = []; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @return bool |
51
|
|
|
*/ |
52
|
|
|
public function hasMapTypeControl() |
53
|
|
|
{ |
54
|
|
|
return $this->mapTypeControl !== null; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return MapTypeControl|null |
59
|
|
|
*/ |
60
|
|
|
public function getMapTypeControl() |
61
|
|
|
{ |
62
|
|
|
return $this->mapTypeControl; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param MapTypeControl|null $mapTypeControl |
67
|
|
|
*/ |
68
|
|
|
public function setMapTypeControl(MapTypeControl $mapTypeControl = null) |
69
|
|
|
{ |
70
|
|
|
$this->mapTypeControl = $mapTypeControl; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return bool |
75
|
|
|
*/ |
76
|
|
|
public function hasRotateControl() |
77
|
|
|
{ |
78
|
|
|
return $this->rotateControl !== null; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return RotateControl|null |
83
|
|
|
*/ |
84
|
|
|
public function getRotateControl() |
85
|
|
|
{ |
86
|
|
|
return $this->rotateControl; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @param RotateControl|null $rotateControl |
91
|
|
|
*/ |
92
|
|
|
public function setRotateControl(RotateControl $rotateControl = null) |
93
|
|
|
{ |
94
|
|
|
$this->rotateControl = $rotateControl; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return bool |
99
|
|
|
*/ |
100
|
|
|
public function hasScaleControl() |
101
|
|
|
{ |
102
|
|
|
return $this->scaleControl !== null; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @return ScaleControl|null |
107
|
|
|
*/ |
108
|
|
|
public function getScaleControl() |
109
|
|
|
{ |
110
|
|
|
return $this->scaleControl; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @param ScaleControl|null $scaleControl |
115
|
|
|
*/ |
116
|
|
|
public function setScaleControl(ScaleControl $scaleControl = null) |
117
|
|
|
{ |
118
|
|
|
$this->scaleControl = $scaleControl; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @return bool |
123
|
|
|
*/ |
124
|
|
|
public function hasStreetViewControl() |
125
|
|
|
{ |
126
|
|
|
return $this->streetViewControl !== null; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return StreetViewControl|null |
131
|
|
|
*/ |
132
|
|
|
public function getStreetViewControl() |
133
|
|
|
{ |
134
|
|
|
return $this->streetViewControl; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @param StreetViewControl|null $streetViewControl |
139
|
|
|
*/ |
140
|
|
|
public function setStreetViewControl(StreetViewControl $streetViewControl = null) |
141
|
|
|
{ |
142
|
|
|
$this->streetViewControl = $streetViewControl; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @return bool |
147
|
|
|
*/ |
148
|
|
|
public function hasZoomControl() |
149
|
|
|
{ |
150
|
|
|
return $this->zoomControl !== null; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @return ZoomControl|null |
155
|
|
|
*/ |
156
|
|
|
public function getZoomControl() |
157
|
|
|
{ |
158
|
|
|
return $this->zoomControl; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @param ZoomControl|null $zoomControl |
163
|
|
|
*/ |
164
|
|
|
public function setZoomControl(ZoomControl $zoomControl = null) |
165
|
|
|
{ |
166
|
|
|
$this->zoomControl = $zoomControl; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @return bool |
171
|
|
|
*/ |
172
|
|
|
public function hasCustomControls() |
173
|
|
|
{ |
174
|
|
|
return !empty($this->customControls); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @return CustomControl[] |
179
|
|
|
*/ |
180
|
|
|
public function getCustomControls() |
181
|
|
|
{ |
182
|
|
|
return $this->customControls; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @param CustomControl[] $customControls |
187
|
|
|
*/ |
188
|
|
|
public function setCustomControls(array $customControls) |
189
|
|
|
{ |
190
|
|
|
$this->customControls = []; |
191
|
|
|
$this->addCustomControls($customControls); |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @param CustomControl[] $customControls |
196
|
|
|
*/ |
197
|
|
|
public function addCustomControls(array $customControls) |
198
|
|
|
{ |
199
|
|
|
foreach ($customControls as $customControl) { |
200
|
|
|
$this->addCustomControl($customControl); |
201
|
|
|
} |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @param CustomControl $customControl |
206
|
|
|
* |
207
|
|
|
* @return bool |
208
|
|
|
*/ |
209
|
|
|
public function hasCustomControl(CustomControl $customControl) |
210
|
|
|
{ |
211
|
|
|
return in_array($customControl, $this->customControls, true); |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* @param CustomControl $customControl |
216
|
|
|
*/ |
217
|
|
|
public function addCustomControl(CustomControl $customControl) |
218
|
|
|
{ |
219
|
|
|
if (!$this->hasCustomControl($customControl)) { |
220
|
|
|
$this->customControls[] = $customControl; |
221
|
|
|
} |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* @param CustomControl $customControl |
226
|
|
|
*/ |
227
|
|
|
public function removeCustomControl(CustomControl $customControl) |
228
|
|
|
{ |
229
|
|
|
unset($this->customControls[array_search($customControl, $this->customControls, true)]); |
230
|
|
|
$this->customControls = array_values($this->customControls); |
231
|
|
|
} |
232
|
|
|
} |
233
|
|
|
|