1 | <?php |
||
25 | class LayerGroup extends Component |
||
26 | { |
||
27 | use NameTrait; |
||
28 | |||
29 | /** |
||
30 | * @var string the name of the javascript variable that will hold the reference |
||
31 | * to the map object. |
||
32 | */ |
||
33 | public $map; |
||
34 | |||
35 | /** |
||
36 | * @var Layer[] |
||
37 | */ |
||
38 | private $_layers = []; |
||
39 | |||
40 | /** |
||
41 | * Adds a layer to the group. If no name given it will be automatically generated. |
||
42 | * |
||
43 | * @param Layer $layer |
||
44 | * |
||
45 | * @return $this |
||
46 | * @throws \yii\base\InvalidParamException |
||
47 | */ |
||
48 | 48 | public function addLayer(Layer $layer) |
|
57 | |||
58 | /** |
||
59 | * Returns a specific layer. Please note that if the layer didn't have a name, it will be dynamically created. This |
||
60 | * method works for those that we know the name previously. |
||
61 | * |
||
62 | * @param string $name the name of the layer |
||
63 | * |
||
64 | * @return mixed |
||
65 | */ |
||
66 | 3 | public function getLayer($name) |
|
70 | |||
71 | /** |
||
72 | * Removes a layer with the given name from the group. |
||
73 | * |
||
74 | * @param $name |
||
75 | * |
||
76 | * @return mixed|null |
||
77 | */ |
||
78 | 3 | public function removeLayer($name) |
|
82 | |||
83 | /** |
||
84 | * @return Layer[] the added layers |
||
85 | */ |
||
86 | 39 | public function getLayers() |
|
90 | |||
91 | /** |
||
92 | * @return JsExpression |
||
93 | */ |
||
94 | 9 | public function encode() |
|
113 | |||
114 | /** |
||
115 | * Returns the initialization |
||
116 | * @return JsExpression |
||
117 | */ |
||
118 | 15 | public function oneLineEncode() |
|
131 | } |
||
132 |