|
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\Layer; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @author GeLo <[email protected]> |
|
16
|
|
|
*/ |
|
17
|
|
|
class LayerManager |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var KmlLayer[] |
|
21
|
|
|
*/ |
|
22
|
|
|
private $kmlLayers = []; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @return bool |
|
26
|
|
|
*/ |
|
27
|
|
|
public function hasKmlLayers() |
|
28
|
|
|
{ |
|
29
|
|
|
return !empty($this->kmlLayers); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @return KmlLayer[] |
|
34
|
|
|
*/ |
|
35
|
|
|
public function getKmlLayers() |
|
36
|
|
|
{ |
|
37
|
|
|
return $this->kmlLayers; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @param KmlLayer[] $kmlLayers |
|
42
|
|
|
*/ |
|
43
|
|
|
public function setKmlLayers(array $kmlLayers) |
|
44
|
|
|
{ |
|
45
|
|
|
$this->kmlLayers = []; |
|
46
|
|
|
$this->addKmlLayers($kmlLayers); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param KmlLayer[] $kmlLayers |
|
51
|
|
|
*/ |
|
52
|
|
|
public function addKmlLayers(array $kmlLayers) |
|
53
|
|
|
{ |
|
54
|
|
|
foreach ($kmlLayers as $kmlLayer) { |
|
55
|
|
|
$this->addKmlLayer($kmlLayer); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @param KmlLayer $kmlLayer |
|
61
|
|
|
* |
|
62
|
|
|
* @return bool |
|
63
|
|
|
*/ |
|
64
|
|
|
public function hasKmlLayer(KmlLayer $kmlLayer) |
|
65
|
|
|
{ |
|
66
|
|
|
return in_array($kmlLayer, $this->kmlLayers, true); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @param KmlLayer $kmlLayer |
|
71
|
|
|
*/ |
|
72
|
|
|
public function addKmlLayer(KmlLayer $kmlLayer) |
|
73
|
|
|
{ |
|
74
|
|
|
if (!$this->hasKmlLayer($kmlLayer)) { |
|
75
|
|
|
$this->kmlLayers[] = $kmlLayer; |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @param KmlLayer $kmlLayer |
|
81
|
|
|
*/ |
|
82
|
|
|
public function removeKmlLayer(KmlLayer $kmlLayer) |
|
83
|
|
|
{ |
|
84
|
|
|
unset($this->kmlLayers[array_search($kmlLayer, $this->kmlLayers, true)]); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|