|
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\Base\Coordinate; |
|
15
|
|
|
use Ivory\GoogleMap\Utility\OptionsAwareInterface; |
|
16
|
|
|
use Ivory\GoogleMap\Utility\OptionsAwareTrait; |
|
17
|
|
|
use Ivory\GoogleMap\Utility\VariableAwareTrait; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Marker |
|
21
|
|
|
* |
|
22
|
|
|
* @author GeLo <[email protected]> |
|
23
|
|
|
*/ |
|
24
|
|
|
class Marker implements ExtendableInterface, OptionsAwareInterface |
|
25
|
|
|
{ |
|
26
|
|
|
use OptionsAwareTrait; |
|
27
|
|
|
use VariableAwareTrait; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var Coordinate |
|
31
|
|
|
*/ |
|
32
|
|
|
private $position; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var string|null |
|
36
|
|
|
*/ |
|
37
|
|
|
private $animation; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var Icon|null |
|
41
|
|
|
*/ |
|
42
|
|
|
private $icon; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var Symbol|null |
|
46
|
|
|
*/ |
|
47
|
|
|
private $symbol; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var MarkerShape|null |
|
51
|
|
|
*/ |
|
52
|
|
|
private $shape; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @var InfoWindow|null |
|
56
|
|
|
*/ |
|
57
|
|
|
private $infoWindow; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @param Coordinate $position |
|
61
|
|
|
* @param string|null $animation |
|
62
|
|
|
* @param Icon|null $icon |
|
63
|
|
|
* @param MarkerShape|null $shape |
|
64
|
|
|
* @param Symbol|null $symbol |
|
65
|
|
|
* @param mixed[] $options |
|
66
|
|
|
*/ |
|
67
|
160 |
|
public function __construct( |
|
68
|
|
|
Coordinate $position, |
|
69
|
|
|
$animation = null, |
|
70
|
|
|
Icon $icon = null, |
|
71
|
|
|
Symbol $symbol = null, |
|
72
|
|
|
MarkerShape $shape = null, |
|
73
|
|
|
array $options = [] |
|
74
|
|
|
) { |
|
75
|
160 |
|
$this->setPosition($position); |
|
76
|
160 |
|
$this->setAnimation($animation); |
|
77
|
160 |
|
$this->setShape($shape); |
|
78
|
160 |
|
$this->addOptions($options); |
|
79
|
|
|
|
|
80
|
160 |
|
if ($icon !== null) { |
|
81
|
8 |
|
$this->setIcon($icon); |
|
82
|
158 |
|
} elseif ($symbol !== null) { |
|
83
|
8 |
|
$this->setSymbol($symbol); |
|
84
|
4 |
|
} |
|
85
|
160 |
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @return Coordinate |
|
89
|
|
|
*/ |
|
90
|
80 |
|
public function getPosition() |
|
91
|
|
|
{ |
|
92
|
80 |
|
return $this->position; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @param Coordinate $position |
|
97
|
|
|
*/ |
|
98
|
160 |
|
public function setPosition(Coordinate $position) |
|
99
|
|
|
{ |
|
100
|
160 |
|
$this->position = $position; |
|
101
|
160 |
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* @return bool |
|
105
|
|
|
*/ |
|
106
|
80 |
|
public function hasAnimation() |
|
107
|
|
|
{ |
|
108
|
80 |
|
return $this->animation !== null; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* @return string|null |
|
113
|
|
|
*/ |
|
114
|
32 |
|
public function getAnimation() |
|
115
|
|
|
{ |
|
116
|
32 |
|
return $this->animation; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @param string|null $animation |
|
121
|
|
|
*/ |
|
122
|
160 |
|
public function setAnimation($animation = null) |
|
123
|
|
|
{ |
|
124
|
160 |
|
$this->animation = $animation; |
|
125
|
160 |
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* @return bool |
|
129
|
|
|
*/ |
|
130
|
100 |
|
public function hasIcon() |
|
131
|
|
|
{ |
|
132
|
100 |
|
return $this->icon !== null; |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* @return Icon|null |
|
137
|
|
|
*/ |
|
138
|
52 |
|
public function getIcon() |
|
139
|
|
|
{ |
|
140
|
52 |
|
return $this->icon; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* @param Icon|null $icon |
|
145
|
|
|
*/ |
|
146
|
68 |
|
public function setIcon(Icon $icon = null) |
|
147
|
|
|
{ |
|
148
|
68 |
|
$this->icon = $icon; |
|
149
|
|
|
|
|
150
|
68 |
|
if ($icon !== null) { |
|
151
|
44 |
|
$this->setSymbol(null); |
|
152
|
22 |
|
} |
|
153
|
68 |
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* @return bool |
|
157
|
|
|
*/ |
|
158
|
84 |
|
public function hasSymbol() |
|
159
|
|
|
{ |
|
160
|
84 |
|
return $this->symbol !== null; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* @return Symbol|null |
|
165
|
|
|
*/ |
|
166
|
36 |
|
public function getSymbol() |
|
167
|
|
|
{ |
|
168
|
36 |
|
return $this->symbol; |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* @param Symbol|null $symbol |
|
173
|
|
|
*/ |
|
174
|
68 |
|
public function setSymbol(Symbol $symbol = null) |
|
175
|
|
|
{ |
|
176
|
68 |
|
$this->symbol = $symbol; |
|
177
|
|
|
|
|
178
|
68 |
|
if ($symbol !== null) { |
|
179
|
32 |
|
$this->setIcon(null); |
|
180
|
16 |
|
} |
|
181
|
68 |
|
} |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* @return bool |
|
185
|
|
|
*/ |
|
186
|
84 |
|
public function hasShape() |
|
187
|
|
|
{ |
|
188
|
84 |
|
return $this->shape !== null; |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
/** |
|
192
|
|
|
* @return MarkerShape|null |
|
193
|
|
|
*/ |
|
194
|
36 |
|
public function getShape() |
|
195
|
|
|
{ |
|
196
|
36 |
|
return $this->shape; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
/** |
|
200
|
|
|
* @param MarkerShape|null $shape |
|
201
|
|
|
*/ |
|
202
|
160 |
|
public function setShape(MarkerShape $shape = null) |
|
203
|
|
|
{ |
|
204
|
160 |
|
$this->shape = $shape; |
|
205
|
160 |
|
} |
|
206
|
|
|
|
|
207
|
|
|
/** |
|
208
|
|
|
* @return bool |
|
209
|
|
|
*/ |
|
210
|
100 |
|
public function hasInfoWindow() |
|
211
|
|
|
{ |
|
212
|
100 |
|
return $this->infoWindow !== null; |
|
213
|
|
|
} |
|
214
|
|
|
|
|
215
|
|
|
/** |
|
216
|
|
|
* @return InfoWindow|null |
|
217
|
|
|
*/ |
|
218
|
60 |
|
public function getInfoWindow() |
|
219
|
|
|
{ |
|
220
|
60 |
|
return $this->infoWindow; |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
/** |
|
224
|
|
|
* @param InfoWindow|null $infoWindow |
|
225
|
|
|
*/ |
|
226
|
24 |
|
public function setInfoWindow(InfoWindow $infoWindow = null) |
|
227
|
|
|
{ |
|
228
|
24 |
|
$this->infoWindow = $infoWindow; |
|
229
|
24 |
|
} |
|
230
|
|
|
} |
|
231
|
|
|
|