|
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\Overlay; |
|
13
|
|
|
|
|
14
|
|
|
use Ivory\GoogleMap\Map; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @author GeLo <[email protected]> |
|
18
|
|
|
*/ |
|
19
|
|
|
class OverlayManager |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @var Map|null |
|
23
|
|
|
*/ |
|
24
|
|
|
private $map; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var MarkerCluster |
|
28
|
|
|
*/ |
|
29
|
|
|
private $markerCluster; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var InfoWindow[] |
|
33
|
|
|
*/ |
|
34
|
|
|
private $infoWindows = []; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var Polyline[] |
|
38
|
|
|
*/ |
|
39
|
|
|
private $polylines = []; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var EncodedPolyline[] |
|
43
|
|
|
*/ |
|
44
|
|
|
private $encodedPolylines = []; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var Polygon[] |
|
48
|
|
|
*/ |
|
49
|
|
|
private $polygons = []; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @var Rectangle[] |
|
53
|
|
|
*/ |
|
54
|
|
|
private $rectangles = []; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @var Circle[] |
|
58
|
|
|
*/ |
|
59
|
|
|
private $circles = []; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @var GroundOverlay[] |
|
63
|
|
|
*/ |
|
64
|
|
|
private $groundOverlays = []; |
|
65
|
|
|
|
|
66
|
960 |
|
public function __construct() |
|
67
|
|
|
{ |
|
68
|
960 |
|
$this->setMarkerCluster(new MarkerCluster()); |
|
69
|
960 |
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @return bool |
|
73
|
|
|
*/ |
|
74
|
504 |
|
public function hasMap() |
|
75
|
|
|
{ |
|
76
|
504 |
|
return $this->map !== null; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @return Map|null |
|
81
|
|
|
*/ |
|
82
|
928 |
|
public function getMap() |
|
83
|
|
|
{ |
|
84
|
928 |
|
return $this->map; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @param Map $map |
|
89
|
|
|
*/ |
|
90
|
960 |
|
public function setMap(Map $map) |
|
91
|
|
|
{ |
|
92
|
960 |
|
$this->map = $map; |
|
93
|
|
|
|
|
94
|
960 |
|
if ($map->getOverlayManager() !== $this) { |
|
95
|
264 |
|
$map->setOverlayManager($this); |
|
96
|
132 |
|
} |
|
97
|
960 |
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @return MarkerCluster |
|
101
|
|
|
*/ |
|
102
|
960 |
|
public function getMarkerCluster() |
|
103
|
|
|
{ |
|
104
|
960 |
|
return $this->markerCluster; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @param MarkerCluster $markerCluster |
|
109
|
|
|
*/ |
|
110
|
960 |
|
public function setMarkerCluster(MarkerCluster $markerCluster) |
|
111
|
|
|
{ |
|
112
|
960 |
|
$this->markerCluster = $markerCluster; |
|
113
|
|
|
|
|
114
|
960 |
|
if ($markerCluster->getOverlayManager() !== $this) { |
|
115
|
960 |
|
$markerCluster->setOverlayManager($this); |
|
116
|
480 |
|
} |
|
117
|
960 |
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @return bool |
|
121
|
|
|
*/ |
|
122
|
8 |
|
public function hasMarkers() |
|
123
|
|
|
{ |
|
124
|
8 |
|
return $this->markerCluster->hasMarkers(); |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* @return Marker[] |
|
129
|
|
|
*/ |
|
130
|
424 |
|
public function getMarkers() |
|
131
|
|
|
{ |
|
132
|
424 |
|
return $this->markerCluster->getMarkers(); |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* @param Marker[] $markers |
|
137
|
|
|
*/ |
|
138
|
4 |
|
public function setMarkers(array $markers) |
|
139
|
|
|
{ |
|
140
|
4 |
|
$this->markerCluster->setMarkers($markers); |
|
141
|
4 |
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* @param Marker[] $markers |
|
145
|
|
|
*/ |
|
146
|
4 |
|
public function addMarkers(array $markers) |
|
147
|
|
|
{ |
|
148
|
4 |
|
$this->markerCluster->addMarkers($markers); |
|
149
|
4 |
|
} |
|
150
|
|
|
|
|
151
|
|
|
/** |
|
152
|
|
|
* @param Marker $marker |
|
153
|
|
|
* |
|
154
|
|
|
* @return bool |
|
155
|
|
|
*/ |
|
156
|
4 |
|
public function hasMarker(Marker $marker) |
|
157
|
|
|
{ |
|
158
|
4 |
|
return $this->markerCluster->hasMarker($marker); |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* @param Marker $marker |
|
163
|
|
|
*/ |
|
164
|
100 |
|
public function addMarker(Marker $marker) |
|
165
|
|
|
{ |
|
166
|
100 |
|
$this->markerCluster->addMarker($marker); |
|
167
|
100 |
|
} |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* @param Marker $marker |
|
171
|
|
|
*/ |
|
172
|
4 |
|
public function removeMarker(Marker $marker) |
|
173
|
|
|
{ |
|
174
|
4 |
|
$this->markerCluster->removeMarker($marker); |
|
175
|
4 |
|
} |
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* @return bool |
|
179
|
|
|
*/ |
|
180
|
32 |
|
public function hasInfoWindows() |
|
181
|
|
|
{ |
|
182
|
32 |
|
return !empty($this->infoWindows); |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
/** |
|
186
|
|
|
* @return InfoWindow[] |
|
187
|
|
|
*/ |
|
188
|
320 |
|
public function getInfoWindows() |
|
189
|
|
|
{ |
|
190
|
320 |
|
return $this->infoWindows; |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* @param InfoWindow[] $infoWindows |
|
195
|
|
|
*/ |
|
196
|
16 |
|
public function setInfoWindows(array $infoWindows) |
|
197
|
|
|
{ |
|
198
|
16 |
|
foreach ($this->infoWindows as $infoWindow) { |
|
199
|
8 |
|
$this->removeInfoWindow($infoWindow); |
|
200
|
8 |
|
} |
|
201
|
|
|
|
|
202
|
16 |
|
$this->addInfoWindows($infoWindows); |
|
203
|
16 |
|
} |
|
204
|
|
|
|
|
205
|
|
|
/** |
|
206
|
|
|
* @param InfoWindow[] $infoWindows |
|
207
|
|
|
*/ |
|
208
|
16 |
|
public function addInfoWindows(array $infoWindows) |
|
209
|
|
|
{ |
|
210
|
16 |
|
foreach ($infoWindows as $infoWindow) { |
|
211
|
16 |
|
$this->addInfoWindow($infoWindow); |
|
212
|
8 |
|
} |
|
213
|
16 |
|
} |
|
214
|
|
|
|
|
215
|
|
|
/** |
|
216
|
|
|
* @param InfoWindow $infoWindow |
|
217
|
|
|
* |
|
218
|
|
|
* @return bool |
|
219
|
|
|
*/ |
|
220
|
72 |
|
public function hasInfoWindow(InfoWindow $infoWindow) |
|
221
|
|
|
{ |
|
222
|
72 |
|
return in_array($infoWindow, $this->infoWindows, true); |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
/** |
|
226
|
|
|
* @param InfoWindow $infoWindow |
|
227
|
|
|
*/ |
|
228
|
72 |
|
public function addInfoWindow(InfoWindow $infoWindow) |
|
229
|
|
|
{ |
|
230
|
72 |
|
if (!$this->hasInfoWindow($infoWindow)) { |
|
231
|
72 |
|
$this->infoWindows[] = $infoWindow; |
|
232
|
36 |
|
} |
|
233
|
|
|
|
|
234
|
72 |
|
$this->addExtendable($infoWindow); |
|
235
|
72 |
|
} |
|
236
|
|
|
|
|
237
|
|
|
/** |
|
238
|
|
|
* @param InfoWindow $infoWindow |
|
239
|
|
|
*/ |
|
240
|
16 |
|
public function removeInfoWindow(InfoWindow $infoWindow) |
|
241
|
|
|
{ |
|
242
|
16 |
|
unset($this->infoWindows[array_search($infoWindow, $this->infoWindows, true)]); |
|
243
|
16 |
|
$this->infoWindows = empty($this->infoWindows) ? [] : array_values($this->infoWindows); |
|
244
|
16 |
|
$this->removeExtendable($infoWindow); |
|
245
|
16 |
|
} |
|
246
|
|
|
|
|
247
|
|
|
/** |
|
248
|
|
|
* @return bool |
|
249
|
|
|
*/ |
|
250
|
32 |
|
public function hasPolylines() |
|
251
|
|
|
{ |
|
252
|
32 |
|
return !empty($this->polylines); |
|
253
|
|
|
} |
|
254
|
|
|
|
|
255
|
|
|
/** |
|
256
|
|
|
* @return Polyline[] |
|
257
|
|
|
*/ |
|
258
|
400 |
|
public function getPolylines() |
|
259
|
|
|
{ |
|
260
|
400 |
|
return $this->polylines; |
|
261
|
|
|
} |
|
262
|
|
|
|
|
263
|
|
|
/** |
|
264
|
|
|
* @param Polyline[] $polylines |
|
265
|
|
|
*/ |
|
266
|
16 |
|
public function setPolylines(array $polylines) |
|
267
|
|
|
{ |
|
268
|
16 |
|
foreach ($this->polylines as $polyline) { |
|
269
|
8 |
|
$this->removePolyline($polyline); |
|
270
|
8 |
|
} |
|
271
|
|
|
|
|
272
|
16 |
|
$this->addPolylines($polylines); |
|
273
|
16 |
|
} |
|
274
|
|
|
|
|
275
|
|
|
/** |
|
276
|
|
|
* @param Polyline[] $polylines |
|
277
|
|
|
*/ |
|
278
|
16 |
|
public function addPolylines(array $polylines) |
|
279
|
|
|
{ |
|
280
|
16 |
|
foreach ($polylines as $polyline) { |
|
281
|
16 |
|
$this->addPolyline($polyline); |
|
282
|
8 |
|
} |
|
283
|
16 |
|
} |
|
284
|
|
|
|
|
285
|
|
|
/** |
|
286
|
|
|
* @param Polyline $polyline |
|
287
|
|
|
* |
|
288
|
|
|
* @return bool |
|
289
|
|
|
*/ |
|
290
|
80 |
|
public function hasPolyline(Polyline $polyline) |
|
291
|
|
|
{ |
|
292
|
80 |
|
return in_array($polyline, $this->polylines, true); |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
|
|
/** |
|
296
|
|
|
* @param Polyline $polyline |
|
297
|
|
|
*/ |
|
298
|
80 |
|
public function addPolyline(Polyline $polyline) |
|
299
|
|
|
{ |
|
300
|
80 |
|
if (!$this->hasPolyline($polyline)) { |
|
301
|
80 |
|
$this->polylines[] = $polyline; |
|
302
|
40 |
|
} |
|
303
|
|
|
|
|
304
|
80 |
|
$this->addExtendable($polyline); |
|
305
|
80 |
|
} |
|
306
|
|
|
|
|
307
|
|
|
/** |
|
308
|
|
|
* @param Polyline $polyline |
|
309
|
|
|
*/ |
|
310
|
16 |
|
public function removePolyline(Polyline $polyline) |
|
311
|
|
|
{ |
|
312
|
16 |
|
unset($this->polylines[array_search($polyline, $this->polylines, true)]); |
|
313
|
16 |
|
$this->polylines = empty($this->polylines) ? [] : array_values($this->polylines); |
|
314
|
16 |
|
$this->removeExtendable($polyline); |
|
315
|
16 |
|
} |
|
316
|
|
|
|
|
317
|
|
|
/** |
|
318
|
|
|
* @return bool |
|
319
|
|
|
*/ |
|
320
|
32 |
|
public function hasEncodedPolylines() |
|
321
|
|
|
{ |
|
322
|
32 |
|
return !empty($this->encodedPolylines); |
|
323
|
|
|
} |
|
324
|
|
|
|
|
325
|
|
|
/** |
|
326
|
|
|
* @return EncodedPolyline[] |
|
327
|
|
|
*/ |
|
328
|
356 |
|
public function getEncodedPolylines() |
|
329
|
|
|
{ |
|
330
|
356 |
|
return $this->encodedPolylines; |
|
331
|
|
|
} |
|
332
|
|
|
|
|
333
|
|
|
/** |
|
334
|
|
|
* @param EncodedPolyline[] $encodedPolylines |
|
335
|
|
|
*/ |
|
336
|
16 |
|
public function setEncodedPolylines(array $encodedPolylines) |
|
337
|
|
|
{ |
|
338
|
16 |
|
foreach ($this->encodedPolylines as $encodedPolyline) { |
|
339
|
8 |
|
$this->removeEncodedPolyline($encodedPolyline); |
|
340
|
8 |
|
} |
|
341
|
|
|
|
|
342
|
16 |
|
$this->addEncodedPolylines($encodedPolylines); |
|
343
|
16 |
|
} |
|
344
|
|
|
|
|
345
|
|
|
/** |
|
346
|
|
|
* @param EncodedPolyline[] $encodedPolylines |
|
347
|
|
|
*/ |
|
348
|
16 |
|
public function addEncodedPolylines(array $encodedPolylines) |
|
349
|
|
|
{ |
|
350
|
16 |
|
foreach ($encodedPolylines as $encodedPolyline) { |
|
351
|
16 |
|
$this->addEncodedPolyline($encodedPolyline); |
|
352
|
8 |
|
} |
|
353
|
16 |
|
} |
|
354
|
|
|
|
|
355
|
|
|
/** |
|
356
|
|
|
* @param EncodedPolyline $encodedPolyline |
|
357
|
|
|
* |
|
358
|
|
|
* @return bool |
|
359
|
|
|
*/ |
|
360
|
60 |
|
public function hasEncodedPolyline(EncodedPolyline $encodedPolyline) |
|
361
|
|
|
{ |
|
362
|
60 |
|
return in_array($encodedPolyline, $this->encodedPolylines, true); |
|
363
|
|
|
} |
|
364
|
|
|
|
|
365
|
|
|
/** |
|
366
|
|
|
* @param EncodedPolyline $encodedPolyline |
|
367
|
|
|
*/ |
|
368
|
60 |
|
public function addEncodedPolyline(EncodedPolyline $encodedPolyline) |
|
369
|
|
|
{ |
|
370
|
60 |
|
if (!$this->hasEncodedPolyline($encodedPolyline)) { |
|
371
|
60 |
|
$this->encodedPolylines[] = $encodedPolyline; |
|
372
|
30 |
|
} |
|
373
|
|
|
|
|
374
|
60 |
|
$this->addExtendable($encodedPolyline); |
|
375
|
60 |
|
} |
|
376
|
|
|
|
|
377
|
|
|
/** |
|
378
|
|
|
* @param EncodedPolyline $encodedPolyline |
|
379
|
|
|
*/ |
|
380
|
16 |
|
public function removeEncodedPolyline(EncodedPolyline $encodedPolyline) |
|
381
|
|
|
{ |
|
382
|
16 |
|
unset($this->encodedPolylines[array_search($encodedPolyline, $this->encodedPolylines, true)]); |
|
383
|
16 |
|
$this->encodedPolylines = empty($this->encodedPolylines) ? [] : array_values($this->encodedPolylines); |
|
384
|
16 |
|
$this->removeExtendable($encodedPolyline); |
|
385
|
16 |
|
} |
|
386
|
|
|
|
|
387
|
|
|
/** |
|
388
|
|
|
* @return bool |
|
389
|
|
|
*/ |
|
390
|
32 |
|
public function hasPolygons() |
|
391
|
|
|
{ |
|
392
|
32 |
|
return !empty($this->polygons); |
|
393
|
|
|
} |
|
394
|
|
|
|
|
395
|
|
|
/** |
|
396
|
|
|
* @return Polygon[] |
|
397
|
|
|
*/ |
|
398
|
288 |
|
public function getPolygons() |
|
399
|
|
|
{ |
|
400
|
288 |
|
return $this->polygons; |
|
401
|
|
|
} |
|
402
|
|
|
|
|
403
|
|
|
/** |
|
404
|
|
|
* @param Polygon[] $polygons |
|
405
|
|
|
*/ |
|
406
|
16 |
|
public function setPolygons(array $polygons) |
|
407
|
|
|
{ |
|
408
|
16 |
|
foreach ($this->polygons as $polygon) { |
|
409
|
8 |
|
$this->removePolygon($polygon); |
|
410
|
8 |
|
} |
|
411
|
|
|
|
|
412
|
16 |
|
$this->addPolygons($polygons); |
|
413
|
16 |
|
} |
|
414
|
|
|
|
|
415
|
|
|
/** |
|
416
|
|
|
* @param Polygon[] $polygons |
|
417
|
|
|
*/ |
|
418
|
16 |
|
public function addPolygons(array $polygons) |
|
419
|
|
|
{ |
|
420
|
16 |
|
foreach ($polygons as $polygon) { |
|
421
|
16 |
|
$this->addPolygon($polygon); |
|
422
|
8 |
|
} |
|
423
|
16 |
|
} |
|
424
|
|
|
|
|
425
|
|
|
/** |
|
426
|
|
|
* @param Polygon $polygon |
|
427
|
|
|
* |
|
428
|
|
|
* @return bool |
|
429
|
|
|
*/ |
|
430
|
48 |
|
public function hasPolygon(Polygon $polygon) |
|
431
|
|
|
{ |
|
432
|
48 |
|
return in_array($polygon, $this->polygons, true); |
|
433
|
|
|
} |
|
434
|
|
|
|
|
435
|
|
|
/** |
|
436
|
|
|
* @param Polygon $polygon |
|
437
|
|
|
*/ |
|
438
|
48 |
|
public function addPolygon(Polygon $polygon) |
|
439
|
|
|
{ |
|
440
|
48 |
|
if (!$this->hasPolygon($polygon)) { |
|
441
|
48 |
|
$this->polygons[] = $polygon; |
|
442
|
24 |
|
} |
|
443
|
|
|
|
|
444
|
48 |
|
$this->addExtendable($polygon); |
|
445
|
48 |
|
} |
|
446
|
|
|
|
|
447
|
|
|
/** |
|
448
|
|
|
* @param Polygon $polygon |
|
449
|
|
|
*/ |
|
450
|
16 |
|
public function removePolygon(Polygon $polygon) |
|
451
|
|
|
{ |
|
452
|
16 |
|
unset($this->polygons[array_search($polygon, $this->polygons, true)]); |
|
453
|
16 |
|
$this->polygons = empty($this->polygons) ? [] : array_values($this->polygons); |
|
454
|
16 |
|
$this->removeExtendable($polygon); |
|
455
|
16 |
|
} |
|
456
|
|
|
|
|
457
|
|
|
/** |
|
458
|
|
|
* @return bool |
|
459
|
|
|
*/ |
|
460
|
32 |
|
public function hasRectangles() |
|
461
|
|
|
{ |
|
462
|
32 |
|
return !empty($this->rectangles); |
|
463
|
|
|
} |
|
464
|
|
|
|
|
465
|
|
|
/** |
|
466
|
|
|
* @return Rectangle[] |
|
467
|
|
|
*/ |
|
468
|
304 |
|
public function getRectangles() |
|
469
|
|
|
{ |
|
470
|
304 |
|
return $this->rectangles; |
|
471
|
|
|
} |
|
472
|
|
|
|
|
473
|
|
|
/** |
|
474
|
|
|
* @param Rectangle[] $rectangles |
|
475
|
|
|
*/ |
|
476
|
16 |
|
public function setRectangles(array $rectangles) |
|
477
|
|
|
{ |
|
478
|
16 |
|
foreach ($this->rectangles as $rectangle) { |
|
479
|
8 |
|
$this->removeRectangle($rectangle); |
|
480
|
8 |
|
} |
|
481
|
|
|
|
|
482
|
16 |
|
$this->addRectangles($rectangles); |
|
483
|
16 |
|
} |
|
484
|
|
|
|
|
485
|
|
|
/** |
|
486
|
|
|
* @param Rectangle[] $rectangles |
|
487
|
|
|
*/ |
|
488
|
16 |
|
public function addRectangles(array $rectangles) |
|
489
|
|
|
{ |
|
490
|
16 |
|
foreach ($rectangles as $rectangle) { |
|
491
|
16 |
|
$this->addRectangle($rectangle); |
|
492
|
8 |
|
} |
|
493
|
16 |
|
} |
|
494
|
|
|
|
|
495
|
|
|
/** |
|
496
|
|
|
* @param Rectangle $rectangle |
|
497
|
|
|
* |
|
498
|
|
|
* @return bool |
|
499
|
|
|
*/ |
|
500
|
52 |
|
public function hasRectangle(Rectangle $rectangle) |
|
501
|
|
|
{ |
|
502
|
52 |
|
return in_array($rectangle, $this->rectangles, true); |
|
503
|
|
|
} |
|
504
|
|
|
|
|
505
|
|
|
/** |
|
506
|
|
|
* @param Rectangle $rectangle |
|
507
|
|
|
*/ |
|
508
|
52 |
|
public function addRectangle(Rectangle $rectangle) |
|
509
|
|
|
{ |
|
510
|
52 |
|
if (!$this->hasRectangle($rectangle)) { |
|
511
|
52 |
|
$this->rectangles[] = $rectangle; |
|
512
|
26 |
|
} |
|
513
|
|
|
|
|
514
|
52 |
|
$this->addExtendable($rectangle); |
|
515
|
52 |
|
} |
|
516
|
|
|
|
|
517
|
|
|
/** |
|
518
|
|
|
* @param Rectangle $rectangle |
|
519
|
|
|
*/ |
|
520
|
16 |
|
public function removeRectangle(Rectangle $rectangle) |
|
521
|
|
|
{ |
|
522
|
16 |
|
unset($this->rectangles[array_search($rectangle, $this->rectangles, true)]); |
|
523
|
16 |
|
$this->rectangles = empty($this->rectangles) ? [] : array_values($this->rectangles); |
|
524
|
16 |
|
$this->removeExtendable($rectangle); |
|
525
|
16 |
|
} |
|
526
|
|
|
|
|
527
|
|
|
/** |
|
528
|
|
|
* @return bool |
|
529
|
|
|
*/ |
|
530
|
32 |
|
public function hasCircles() |
|
531
|
|
|
{ |
|
532
|
32 |
|
return !empty($this->circles); |
|
533
|
|
|
} |
|
534
|
|
|
|
|
535
|
|
|
/** |
|
536
|
|
|
* @return Circle[] |
|
537
|
|
|
*/ |
|
538
|
288 |
|
public function getCircles() |
|
539
|
|
|
{ |
|
540
|
288 |
|
return $this->circles; |
|
541
|
|
|
} |
|
542
|
|
|
|
|
543
|
|
|
/** |
|
544
|
|
|
* @param Circle[] $circles |
|
545
|
|
|
*/ |
|
546
|
16 |
|
public function setCircles(array $circles) |
|
547
|
|
|
{ |
|
548
|
16 |
|
foreach ($this->circles as $circle) { |
|
549
|
8 |
|
$this->removeCircle($circle); |
|
550
|
8 |
|
} |
|
551
|
|
|
|
|
552
|
16 |
|
$this->addCircles($circles); |
|
553
|
16 |
|
} |
|
554
|
|
|
|
|
555
|
|
|
/** |
|
556
|
|
|
* @param Circle[] $circles |
|
557
|
|
|
*/ |
|
558
|
16 |
|
public function addCircles(array $circles) |
|
559
|
|
|
{ |
|
560
|
16 |
|
foreach ($circles as $circle) { |
|
561
|
16 |
|
$this->addCircle($circle); |
|
562
|
8 |
|
} |
|
563
|
16 |
|
} |
|
564
|
|
|
|
|
565
|
|
|
/** |
|
566
|
|
|
* @param Circle $circle |
|
567
|
|
|
* |
|
568
|
|
|
* @return bool |
|
569
|
|
|
*/ |
|
570
|
48 |
|
public function hasCircle(Circle $circle) |
|
571
|
|
|
{ |
|
572
|
48 |
|
return in_array($circle, $this->circles, true); |
|
573
|
|
|
} |
|
574
|
|
|
|
|
575
|
|
|
/** |
|
576
|
|
|
* @param Circle $circle |
|
577
|
|
|
*/ |
|
578
|
48 |
|
public function addCircle(Circle $circle) |
|
579
|
|
|
{ |
|
580
|
48 |
|
if (!$this->hasCircle($circle)) { |
|
581
|
48 |
|
$this->circles[] = $circle; |
|
582
|
24 |
|
} |
|
583
|
|
|
|
|
584
|
48 |
|
$this->addExtendable($circle); |
|
585
|
48 |
|
} |
|
586
|
|
|
|
|
587
|
|
|
/** |
|
588
|
|
|
* @param Circle $circle |
|
589
|
|
|
*/ |
|
590
|
16 |
|
public function removeCircle(Circle $circle) |
|
591
|
|
|
{ |
|
592
|
16 |
|
unset($this->circles[array_search($circle, $this->circles, true)]); |
|
593
|
16 |
|
$this->circles = empty($this->circles) ? [] : array_values($this->circles); |
|
594
|
16 |
|
$this->removeExtendable($circle); |
|
595
|
16 |
|
} |
|
596
|
|
|
|
|
597
|
|
|
/** |
|
598
|
|
|
* @return bool |
|
599
|
|
|
*/ |
|
600
|
32 |
|
public function hasGroundOverlays() |
|
601
|
|
|
{ |
|
602
|
32 |
|
return !empty($this->groundOverlays); |
|
603
|
|
|
} |
|
604
|
|
|
|
|
605
|
|
|
/** |
|
606
|
|
|
* @return GroundOverlay[] |
|
607
|
|
|
*/ |
|
608
|
304 |
|
public function getGroundOverlays() |
|
609
|
|
|
{ |
|
610
|
304 |
|
return $this->groundOverlays; |
|
611
|
|
|
} |
|
612
|
|
|
|
|
613
|
|
|
/** |
|
614
|
|
|
* @param GroundOverlay[] $groundOverlays |
|
615
|
|
|
*/ |
|
616
|
16 |
|
public function setGroundOverlays(array $groundOverlays) |
|
617
|
|
|
{ |
|
618
|
16 |
|
foreach ($this->groundOverlays as $groundOverlay) { |
|
619
|
8 |
|
$this->removeGroundOverlay($groundOverlay); |
|
620
|
8 |
|
} |
|
621
|
|
|
|
|
622
|
16 |
|
$this->addGroundOverlays($groundOverlays); |
|
623
|
16 |
|
} |
|
624
|
|
|
|
|
625
|
|
|
/** |
|
626
|
|
|
* @param GroundOverlay[] $groundOverlays |
|
627
|
|
|
*/ |
|
628
|
16 |
|
public function addGroundOverlays(array $groundOverlays) |
|
629
|
|
|
{ |
|
630
|
16 |
|
foreach ($groundOverlays as $groundOverlay) { |
|
631
|
16 |
|
$this->addGroundOverlay($groundOverlay); |
|
632
|
8 |
|
} |
|
633
|
16 |
|
} |
|
634
|
|
|
|
|
635
|
|
|
/** |
|
636
|
|
|
* @param GroundOverlay $groundOverlay |
|
637
|
|
|
* |
|
638
|
|
|
* @return bool |
|
639
|
|
|
*/ |
|
640
|
48 |
|
public function hasGroundOverlay(GroundOverlay $groundOverlay) |
|
641
|
|
|
{ |
|
642
|
48 |
|
return in_array($groundOverlay, $this->groundOverlays, true); |
|
643
|
|
|
} |
|
644
|
|
|
|
|
645
|
|
|
/** |
|
646
|
|
|
* @param GroundOverlay $groundOverlay |
|
647
|
|
|
*/ |
|
648
|
48 |
|
public function addGroundOverlay(GroundOverlay $groundOverlay) |
|
649
|
|
|
{ |
|
650
|
48 |
|
if (!$this->hasGroundOverlay($groundOverlay)) { |
|
651
|
48 |
|
$this->groundOverlays[] = $groundOverlay; |
|
652
|
24 |
|
} |
|
653
|
|
|
|
|
654
|
48 |
|
$this->addExtendable($groundOverlay); |
|
655
|
48 |
|
} |
|
656
|
|
|
|
|
657
|
|
|
/** |
|
658
|
|
|
* @param GroundOverlay $groundOverlay |
|
659
|
|
|
*/ |
|
660
|
16 |
|
public function removeGroundOverlay(GroundOverlay $groundOverlay) |
|
661
|
|
|
{ |
|
662
|
16 |
|
unset($this->groundOverlays[array_search($groundOverlay, $this->groundOverlays, true)]); |
|
663
|
16 |
|
$this->groundOverlays = empty($this->groundOverlays) ? [] : array_values($this->groundOverlays); |
|
664
|
16 |
|
$this->removeExtendable($groundOverlay); |
|
665
|
16 |
|
} |
|
666
|
|
|
|
|
667
|
|
|
/** |
|
668
|
|
|
* @param ExtendableInterface $extendable |
|
669
|
|
|
*/ |
|
670
|
404 |
|
private function addExtendable(ExtendableInterface $extendable) |
|
671
|
|
|
{ |
|
672
|
404 |
|
if ($this->isAutoZoom()) { |
|
673
|
152 |
|
$this->getMap()->getBound()->addExtendable($extendable); |
|
674
|
76 |
|
} |
|
675
|
404 |
|
} |
|
676
|
|
|
|
|
677
|
|
|
/** |
|
678
|
|
|
* @param ExtendableInterface $extendable |
|
679
|
|
|
*/ |
|
680
|
112 |
|
private function removeExtendable(ExtendableInterface $extendable) |
|
681
|
|
|
{ |
|
682
|
112 |
|
if ($this->isAutoZoom()) { |
|
683
|
56 |
|
$this->getMap()->getBound()->removeExtendable($extendable); |
|
684
|
28 |
|
} |
|
685
|
112 |
|
} |
|
686
|
|
|
|
|
687
|
|
|
/** |
|
688
|
|
|
* @return bool |
|
689
|
|
|
*/ |
|
690
|
404 |
|
private function isAutoZoom() |
|
691
|
|
|
{ |
|
692
|
404 |
|
return $this->hasMap() && $this->getMap()->isAutoZoom(); |
|
693
|
|
|
} |
|
694
|
|
|
} |
|
695
|
|
|
|