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
|
|
|
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
|
|
|
$this->setPosition($position); |
76
|
|
|
$this->setAnimation($animation); |
77
|
|
|
$this->setShape($shape); |
78
|
|
|
$this->addOptions($options); |
79
|
|
|
|
80
|
|
|
if ($icon !== null) { |
81
|
|
|
$this->setIcon($icon); |
82
|
|
|
} elseif ($symbol !== null) { |
83
|
|
|
$this->setSymbol($symbol); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return Coordinate |
89
|
|
|
*/ |
90
|
|
|
public function getPosition() |
91
|
|
|
{ |
92
|
|
|
return $this->position; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @param Coordinate $position |
97
|
|
|
*/ |
98
|
|
|
public function setPosition(Coordinate $position) |
99
|
|
|
{ |
100
|
|
|
$this->position = $position; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return bool |
105
|
|
|
*/ |
106
|
|
|
public function hasAnimation() |
107
|
|
|
{ |
108
|
|
|
return $this->animation !== null; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return string|null |
113
|
|
|
*/ |
114
|
|
|
public function getAnimation() |
115
|
|
|
{ |
116
|
|
|
return $this->animation; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @param string|null $animation |
121
|
|
|
*/ |
122
|
|
|
public function setAnimation($animation = null) |
123
|
|
|
{ |
124
|
|
|
$this->animation = $animation; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @return bool |
129
|
|
|
*/ |
130
|
|
|
public function hasIcon() |
131
|
|
|
{ |
132
|
|
|
return $this->icon !== null; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @return Icon|null |
137
|
|
|
*/ |
138
|
|
|
public function getIcon() |
139
|
|
|
{ |
140
|
|
|
return $this->icon; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @param Icon|null $icon |
145
|
|
|
*/ |
146
|
|
|
public function setIcon(Icon $icon = null) |
147
|
|
|
{ |
148
|
|
|
$this->icon = $icon; |
149
|
|
|
|
150
|
|
|
if ($icon !== null) { |
151
|
|
|
$this->setSymbol(null); |
152
|
|
|
} |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @return bool |
157
|
|
|
*/ |
158
|
|
|
public function hasSymbol() |
159
|
|
|
{ |
160
|
|
|
return $this->symbol !== null; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @return Symbol|null |
165
|
|
|
*/ |
166
|
|
|
public function getSymbol() |
167
|
|
|
{ |
168
|
|
|
return $this->symbol; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @param Symbol|null $symbol |
173
|
|
|
*/ |
174
|
|
|
public function setSymbol(Symbol $symbol = null) |
175
|
|
|
{ |
176
|
|
|
$this->symbol = $symbol; |
177
|
|
|
|
178
|
|
|
if ($symbol !== null) { |
179
|
|
|
$this->setIcon(null); |
180
|
|
|
} |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @return bool |
185
|
|
|
*/ |
186
|
|
|
public function hasShape() |
187
|
|
|
{ |
188
|
|
|
return $this->shape !== null; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* @return MarkerShape|null |
193
|
|
|
*/ |
194
|
|
|
public function getShape() |
195
|
|
|
{ |
196
|
|
|
return $this->shape; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @param MarkerShape|null $shape |
201
|
|
|
*/ |
202
|
|
|
public function setShape(MarkerShape $shape = null) |
203
|
|
|
{ |
204
|
|
|
$this->shape = $shape; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* @return bool |
209
|
|
|
*/ |
210
|
|
|
public function hasInfoWindow() |
211
|
|
|
{ |
212
|
|
|
return $this->infoWindow !== null; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* @return InfoWindow|null |
217
|
|
|
*/ |
218
|
|
|
public function getInfoWindow() |
219
|
|
|
{ |
220
|
|
|
return $this->infoWindow; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* @param InfoWindow|null $infoWindow |
225
|
|
|
*/ |
226
|
|
|
public function setInfoWindow(InfoWindow $infoWindow = null) |
227
|
|
|
{ |
228
|
|
|
$this->infoWindow = $infoWindow; |
229
|
|
|
} |
230
|
|
|
} |
231
|
|
|
|