|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Ivory Google Map package. |
|
7
|
|
|
* |
|
8
|
|
|
* (c) Eric GELOEN <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please read the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Ivory\GoogleMap\Helper\Collector\Base; |
|
15
|
|
|
|
|
16
|
|
|
use Ivory\GoogleMap\Base\Size; |
|
17
|
|
|
use Ivory\GoogleMap\Helper\Collector\AbstractCollector; |
|
18
|
|
|
use Ivory\GoogleMap\Helper\Collector\Overlay\IconCollector; |
|
19
|
|
|
use Ivory\GoogleMap\Helper\Collector\Overlay\InfoWindowCollector; |
|
20
|
|
|
use Ivory\GoogleMap\Map; |
|
21
|
|
|
|
|
22
|
|
|
class SizeCollector extends AbstractCollector |
|
23
|
|
|
{ |
|
24
|
|
|
/** @var InfoWindowCollector */ |
|
25
|
|
|
private $infoWindowCollector; |
|
26
|
|
|
|
|
27
|
|
|
/** @var IconCollector */ |
|
28
|
|
|
private $iconCollector; |
|
29
|
|
|
|
|
30
|
6 |
|
public function __construct(InfoWindowCollector $infoWindowCollector, IconCollector $iconCollector) |
|
31
|
|
|
{ |
|
32
|
6 |
|
$this->setInfoWindowCollector($infoWindowCollector); |
|
33
|
6 |
|
$this->setIconCollector($iconCollector); |
|
34
|
6 |
|
} |
|
35
|
|
|
|
|
36
|
1 |
|
public function getInfoWindowCollector(): InfoWindowCollector |
|
37
|
|
|
{ |
|
38
|
1 |
|
return $this->infoWindowCollector; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
6 |
|
public function setInfoWindowCollector(InfoWindowCollector $infoWindowCollector): void |
|
42
|
|
|
{ |
|
43
|
6 |
|
$this->infoWindowCollector = $infoWindowCollector; |
|
44
|
6 |
|
} |
|
45
|
|
|
|
|
46
|
1 |
|
public function getIconCollector(): IconCollector |
|
47
|
|
|
{ |
|
48
|
1 |
|
return $this->iconCollector; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
6 |
|
public function setIconCollector(IconCollector $iconCollector): void |
|
52
|
|
|
{ |
|
53
|
6 |
|
$this->iconCollector = $iconCollector; |
|
54
|
6 |
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @param Size[] $sizes |
|
58
|
|
|
* |
|
59
|
|
|
* @return Size[] |
|
60
|
|
|
*/ |
|
61
|
3 |
|
public function collect(Map $map, array $sizes = []): array |
|
62
|
|
|
{ |
|
63
|
3 |
|
foreach ($this->infoWindowCollector->collect($map) as $infoWindow) { |
|
64
|
1 |
|
if ($infoWindow->hasPixelOffset()) { |
|
65
|
1 |
|
$sizes = $this->collectValue($infoWindow->getPixelOffset(), $sizes); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
3 |
|
foreach ($this->iconCollector->collect($map) as $icon) { |
|
70
|
1 |
|
if ($icon->hasSize()) { |
|
71
|
1 |
|
$sizes = $this->collectValue($icon->getSize(), $sizes); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
1 |
|
if ($icon->hasScaledSize()) { |
|
75
|
1 |
|
$sizes = $this->collectValue($icon->getScaledSize(), $sizes); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
3 |
|
return $sizes; |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|