1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Cornford\Googlmapper; |
4
|
|
|
|
5
|
|
|
use Cornford\Googlmapper\Contracts\MappingBaseInterface; |
6
|
|
|
use Cornford\Googlmapper\Exceptions\MapperArgumentException; |
7
|
|
|
use Cornford\Googlmapper\Traits\Languages; |
8
|
|
|
use Cornford\Googlmapper\Traits\Regions; |
9
|
|
|
use Illuminate\View\Factory as View; |
10
|
|
|
|
11
|
|
|
abstract class MapperBase implements MappingBaseInterface |
12
|
|
|
{ |
13
|
|
|
use Regions; |
14
|
|
|
use Languages; |
15
|
|
|
|
16
|
|
|
private const ENABLED = true; |
17
|
|
|
|
18
|
|
|
private const REGION = 'GB'; |
19
|
|
|
|
20
|
|
|
private const LANGUAGE = 'en-gb'; |
21
|
|
|
|
22
|
|
|
private const TYPE_ROADMAP = 'ROADMAP'; |
23
|
|
|
private const TYPE_SATELLITE = 'SATELLITE'; |
24
|
|
|
private const TYPE_HYBRID = 'HYBRID'; |
25
|
|
|
private const TYPE_TERRAIN = 'TERRAIN'; |
26
|
|
|
|
27
|
|
|
private const ASYNC = false; |
28
|
|
|
|
29
|
|
|
private const MARKER = true; |
30
|
|
|
|
31
|
|
|
private const CENTER = true; |
32
|
|
|
|
33
|
|
|
private const LOCATE = false; |
34
|
|
|
|
35
|
|
|
private const ZOOM = 8; |
36
|
|
|
private const SCROLL_WHEEL_ZOOM = true; |
37
|
|
|
|
38
|
|
|
private const CONTROL_ZOOM = true; |
39
|
|
|
private const CONTROL_MAP_TYPE = true; |
40
|
|
|
private const CONTROL_SCALE = false; |
41
|
|
|
private const CONTROL_STREET_VIEW = true; |
42
|
|
|
private const CONTROL_ROTATE = false; |
43
|
|
|
private const CONTROL_FULLSCREEN = true; |
44
|
|
|
|
45
|
|
|
private const HEADING = 0; |
46
|
|
|
|
47
|
|
|
private const TILT = 0; |
48
|
|
|
|
49
|
|
|
private const UI = true; |
50
|
|
|
|
51
|
|
|
private const ANIMATION_NONE = 'NONE'; |
52
|
|
|
private const ANIMATION_DROP = 'DROP'; |
53
|
|
|
private const ANIMATION_BOUNCE = 'BOUNCE'; |
54
|
|
|
|
55
|
|
|
private const GESTURE_HANDLING_AUTO = 'auto'; |
56
|
|
|
private const GESTURE_HANDLING_NONE = 'none'; |
57
|
|
|
private const GESTURE_HANDLING_GREEDY = 'greedy'; |
58
|
|
|
private const GESTURE_HANDLING_COOPERATIVE = 'cooperative'; |
59
|
|
|
|
60
|
|
|
private const OVERLAY_NONE = 'NONE'; |
61
|
|
|
private const OVERLAY_BIKE = 'BIKE'; |
62
|
|
|
private const OVERLAY_TRANSIT = 'TRANSIT'; |
63
|
|
|
private const OVERLAY_TRAFFIC = 'TRAFFIC'; |
64
|
|
|
|
65
|
|
|
private const SYMBOL_CIRCLE = 'CIRCLE'; |
66
|
|
|
private const SYMBOL_BACKWARD_CLOSED_ARROW = 'BACKWARD_CLOSED_ARROW'; |
67
|
|
|
private const SYMBOL_FORWARD_CLOSED_ARROW = 'FORWARD_CLOSED_ARROW'; |
68
|
|
|
private const SYMBOL_BACKWARD_OPEN_ARROW = 'BACKWARD_OPEN_ARROW'; |
69
|
|
|
private const SYMBOL_FORWARD_OPEN_ARROW = 'FORWARD_OPEN_ARROW'; |
70
|
|
|
|
71
|
|
|
private const ICON = ''; |
72
|
|
|
|
73
|
|
|
private const CLUSTER = true; |
74
|
|
|
|
75
|
|
|
private const CLUSTERS_ICON = '//googlemaps.github.io/js-marker-clusterer/images/m'; |
76
|
|
|
private const CLUSTERS_GRID = 60; |
77
|
|
|
private const CLUSTERS_ZOOM = null; |
78
|
|
|
private const CLUSTERS_CENTER = false; |
79
|
|
|
private const CLUSTERS_SIZE = 2; |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* View. |
83
|
|
|
* |
84
|
|
|
* @var \Illuminate\View\Factory |
85
|
|
|
*/ |
86
|
|
|
protected $view; |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Mapping enabled. |
90
|
|
|
* |
91
|
|
|
* @var boolean |
92
|
|
|
*/ |
93
|
|
|
protected $enabled; |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* API Key. |
97
|
|
|
* |
98
|
|
|
* @var string |
99
|
|
|
*/ |
100
|
|
|
protected $key; |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* API Version. |
104
|
|
|
* |
105
|
|
|
* @var float|string |
106
|
|
|
*/ |
107
|
|
|
protected $version; |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* API region. |
111
|
|
|
* |
112
|
|
|
* @var string |
113
|
|
|
*/ |
114
|
|
|
protected $region; |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* API Language. |
118
|
|
|
* |
119
|
|
|
* @var string |
120
|
|
|
*/ |
121
|
|
|
protected $language; |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Async maps. |
125
|
|
|
* |
126
|
|
|
* @var boolean |
127
|
|
|
*/ |
128
|
|
|
protected $async; |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Automatic map marker. |
132
|
|
|
* |
133
|
|
|
* @var boolean |
134
|
|
|
*/ |
135
|
|
|
protected $marker; |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Center map automatically. |
139
|
|
|
* |
140
|
|
|
* @var boolean |
141
|
|
|
*/ |
142
|
|
|
protected $center; |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Locate users location. |
146
|
|
|
* |
147
|
|
|
* @var boolean |
148
|
|
|
*/ |
149
|
|
|
protected $locate; |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Show map UI. |
153
|
|
|
* |
154
|
|
|
* @var boolean |
155
|
|
|
*/ |
156
|
|
|
protected $ui; |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Map zoom level. |
160
|
|
|
* |
161
|
|
|
* @var int |
162
|
|
|
*/ |
163
|
|
|
protected $zoom; |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* Map scroll wheel zoom. |
167
|
|
|
* |
168
|
|
|
* @var boolean |
169
|
|
|
*/ |
170
|
|
|
protected $scrollWheelZoom; |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* Map zoom control. |
174
|
|
|
* |
175
|
|
|
* @var boolean |
176
|
|
|
*/ |
177
|
|
|
protected $zoomControl; |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* Map type control. |
181
|
|
|
* |
182
|
|
|
* @var boolean |
183
|
|
|
*/ |
184
|
|
|
protected $mapTypeControl; |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* Map scale control. |
188
|
|
|
* |
189
|
|
|
* @var boolean |
190
|
|
|
*/ |
191
|
|
|
protected $scaleControl; |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* Map street view control. |
195
|
|
|
* |
196
|
|
|
* @var boolean |
197
|
|
|
*/ |
198
|
|
|
protected $streetViewControl; |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* Map rotate control. |
202
|
|
|
* |
203
|
|
|
* @var boolean |
204
|
|
|
*/ |
205
|
|
|
protected $rotateControl; |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* Map fullscreen control. |
209
|
|
|
* |
210
|
|
|
* @var boolean |
211
|
|
|
*/ |
212
|
|
|
protected $fullscreenControl; |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* Map type. |
216
|
|
|
* |
217
|
|
|
* @var string |
218
|
|
|
*/ |
219
|
|
|
protected $type; |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* Available map types. |
223
|
|
|
* |
224
|
|
|
* @var array |
225
|
|
|
*/ |
226
|
|
|
protected $types = [ |
227
|
|
|
'ROADMAP', |
228
|
|
|
'SATELLITE', |
229
|
|
|
'HYBRID', |
230
|
|
|
'TERRAIN' |
231
|
|
|
]; |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* Map heading. |
235
|
|
|
* |
236
|
|
|
* @var int |
237
|
|
|
*/ |
238
|
|
|
protected $heading; |
239
|
|
|
|
240
|
|
|
/** |
241
|
|
|
* Map tilt. |
242
|
|
|
* |
243
|
|
|
* @var int |
244
|
|
|
*/ |
245
|
|
|
protected $tilt; |
246
|
|
|
|
247
|
|
|
/** |
248
|
|
|
* Map marker icon. |
249
|
|
|
* |
250
|
|
|
* @var string |
251
|
|
|
*/ |
252
|
|
|
protected $icon; |
253
|
|
|
|
254
|
|
|
/** |
255
|
|
|
* Map marker animation. |
256
|
|
|
* |
257
|
|
|
* @var string |
258
|
|
|
*/ |
259
|
|
|
protected $animation; |
260
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* Available map marker animations. |
263
|
|
|
* |
264
|
|
|
* @var array |
265
|
|
|
*/ |
266
|
|
|
protected $animations = [ |
267
|
|
|
'NONE', |
268
|
|
|
'DROP', |
269
|
|
|
'BOUNCE', |
270
|
|
|
]; |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* Gesture handling. |
274
|
|
|
* |
275
|
|
|
* @var string |
276
|
|
|
*/ |
277
|
|
|
protected $gestureHandling; |
278
|
|
|
|
279
|
|
|
/** |
280
|
|
|
* Available map gesture handlers. |
281
|
|
|
* |
282
|
|
|
* @var array |
283
|
|
|
*/ |
284
|
|
|
protected $gestureHandlers = [ |
285
|
|
|
'auto', |
286
|
|
|
'none', |
287
|
|
|
'greedy', |
288
|
|
|
'cooperative', |
289
|
|
|
]; |
290
|
|
|
|
291
|
|
|
/** |
292
|
|
|
* Map marker cluster. |
293
|
|
|
* |
294
|
|
|
* @var boolean |
295
|
|
|
*/ |
296
|
|
|
protected $cluster; |
297
|
|
|
|
298
|
|
|
/** |
299
|
|
|
* Map marker clusters icon. |
300
|
|
|
* |
301
|
|
|
* @var string |
302
|
|
|
*/ |
303
|
|
|
protected $clustersIcon; |
304
|
|
|
|
305
|
|
|
/** |
306
|
|
|
* Map marker clusters grid. |
307
|
|
|
* |
308
|
|
|
* @var int |
309
|
|
|
*/ |
310
|
|
|
protected $clustersGrid; |
311
|
|
|
|
312
|
|
|
/** |
313
|
|
|
* Map marker clusters zoom. |
314
|
|
|
* |
315
|
|
|
* @var int|null |
316
|
|
|
*/ |
317
|
|
|
protected $clustersZoom; |
318
|
|
|
|
319
|
|
|
/** |
320
|
|
|
* Map marker clusters center. |
321
|
|
|
* |
322
|
|
|
* @var boolean |
323
|
|
|
*/ |
324
|
|
|
protected $clustersCenter; |
325
|
|
|
|
326
|
|
|
/** |
327
|
|
|
* Map marker clusters size. |
328
|
|
|
* |
329
|
|
|
* @var int |
330
|
|
|
*/ |
331
|
|
|
protected $clustersSize; |
332
|
|
|
|
333
|
|
|
/** |
334
|
|
|
* Mapping items. |
335
|
|
|
* |
336
|
|
|
* @var array |
337
|
|
|
*/ |
338
|
|
|
public $items = []; |
339
|
|
|
|
340
|
|
|
/** |
341
|
|
|
* Construct Googlmapper. |
342
|
|
|
* |
343
|
|
|
* @param View $view |
344
|
|
|
* @param array $options |
345
|
|
|
* |
346
|
|
|
* @throws MapperArgumentException |
347
|
|
|
*/ |
348
|
|
|
public function __construct(View $view, array $options = []) |
349
|
|
|
{ |
350
|
|
|
$this->view = $view; |
351
|
|
|
|
352
|
|
|
if (!isset($options['key'])) { |
353
|
|
|
throw new MapperArgumentException('Google maps API key is required.'); |
354
|
|
|
} |
355
|
|
|
|
356
|
|
|
if (!isset($options['version'])) { |
357
|
|
|
throw new MapperArgumentException('Google maps API version is required.'); |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
if (!isset($options['region'])) { |
361
|
|
|
throw new MapperArgumentException('Region is required.'); |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
if (!in_array($options['region'], $this->regions)) { |
365
|
|
|
throw new MapperArgumentException('Region is required in ISO 3166-1 code format.'); |
366
|
|
|
} |
367
|
|
|
|
368
|
|
|
if (!isset($options['language']) || !in_array($options['language'], $this->languages)) { |
369
|
|
|
throw new MapperArgumentException('Language is required.'); |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
if (!in_array($options['language'], $this->languages)) { |
373
|
|
|
throw new MapperArgumentException('Language is required in ISO 639-1 code format.'); |
374
|
|
|
} |
375
|
|
|
|
376
|
|
|
$this->setEnabled($options['enabled'] ?? self::ENABLED); |
377
|
|
|
$this->setKey($options['key']); |
378
|
|
|
$this->setVersion($options['version']); |
379
|
|
|
$this->setRegion($options['region'] ?? self::REGION); |
380
|
|
|
$this->setLanguage($options['language'] ?? self::LANGUAGE); |
381
|
|
|
$this->setAsync($options['async'] ?? self::ASYNC); |
382
|
|
|
$this->setMarker($options['marker'] ?? self::MARKER); |
383
|
|
|
$this->setCenter($options['center'] ?? self::CENTER); |
384
|
|
|
$this->setLocate($options['locate'] ?? self::LOCATE); |
385
|
|
|
$this->setZoom($options['zoom'] ?? self::ZOOM); |
386
|
|
|
$this->setScrollWheelZoom($options['scrollWheelZoom'] ?? self::SCROLL_WHEEL_ZOOM); |
387
|
|
|
$this->setZoomControl($options['zoomControl'] ?? self::CONTROL_ZOOM); |
388
|
|
|
$this->setMapTypeControl($options['mapTypeControl'] ?? self::CONTROL_MAP_TYPE); |
389
|
|
|
$this->setScaleControl($options['scaleControl'] ?? self::CONTROL_SCALE); |
390
|
|
|
$this->setStreetViewControl($options['streetViewControl'] ?? self::CONTROL_STREET_VIEW); |
391
|
|
|
$this->setRotateControl($options['rotateControl'] ?? self::CONTROL_ROTATE); |
392
|
|
|
$this->setFullscreenControl($options['fullscreenControl'] ?? self::CONTROL_FULLSCREEN); |
393
|
|
|
$this->setType($options['type'] ?? self::TYPE_ROADMAP); |
394
|
|
|
$this->setHeading($options['heading'] ?? self::HEADING); |
395
|
|
|
$this->setTilt($options['tilt'] ?? self::TILT); |
396
|
|
|
$this->setUi($options['ui'] ?? self::UI); |
397
|
|
|
$this->setIcon($options['markers']['icon'] ?? self::ICON); |
398
|
|
|
$this->setAnimation($options['markers']['animation'] ?? self::ANIMATION_NONE); |
399
|
|
|
$this->setGestureHandling($options['gestureHandling'] ?? self::GESTURE_HANDLING_AUTO); |
400
|
|
|
$this->setCluster($options['cluster'] ?? self::CLUSTER); |
401
|
|
|
$this->setClustersIcon($options['clusters']['icon'] ?? self::CLUSTERS_ICON); |
402
|
|
|
$this->setClustersGrid($options['clusters']['grid'] ?? self::CLUSTERS_GRID); |
403
|
|
|
$this->setClustersZoom($options['clusters']['zoom'] ?? self::CLUSTERS_ZOOM); |
404
|
|
|
$this->setClustersCenter($options['clusters']['center'] ?? self::CLUSTERS_CENTER); |
405
|
|
|
$this->setClustersSize($options['clusters']['size'] ?? self::CLUSTERS_SIZE); |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
/** |
409
|
|
|
* Is mapping enabled? |
410
|
|
|
* |
411
|
|
|
* @return boolean |
412
|
|
|
*/ |
413
|
|
|
public function isEnabled() |
414
|
|
|
{ |
415
|
|
|
return $this->getEnabled(); |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
/** |
419
|
|
|
* Set enabled status. |
420
|
|
|
* |
421
|
|
|
* @param boolean $value |
422
|
|
|
* |
423
|
|
|
* @throws MapperArgumentException |
424
|
|
|
* |
425
|
|
|
* @return void |
426
|
|
|
*/ |
427
|
|
|
protected function setEnabled($value) |
428
|
|
|
{ |
429
|
|
|
if (!is_bool($value)) { |
430
|
|
|
throw new MapperArgumentException('Invalid map enabled setting.'); |
431
|
|
|
} |
432
|
|
|
|
433
|
|
|
$this->enabled = $value; |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
/** |
437
|
|
|
* Get the enabled status. |
438
|
|
|
* |
439
|
|
|
* @return boolean |
440
|
|
|
*/ |
441
|
|
|
protected function getEnabled() |
442
|
|
|
{ |
443
|
|
|
return $this->enabled; |
444
|
|
|
} |
445
|
|
|
|
446
|
|
|
/** |
447
|
|
|
* Enable mapping. |
448
|
|
|
* |
449
|
|
|
* @throws MapperArgumentException |
450
|
|
|
* |
451
|
|
|
* @return void |
452
|
|
|
*/ |
453
|
|
|
public function enableMapping() |
454
|
|
|
{ |
455
|
|
|
$this->setEnabled(true); |
456
|
|
|
} |
457
|
|
|
|
458
|
|
|
/** |
459
|
|
|
* Disable mapping. |
460
|
|
|
* |
461
|
|
|
* @throws MapperArgumentException |
462
|
|
|
* |
463
|
|
|
* @return void |
464
|
|
|
*/ |
465
|
|
|
public function disableMapping() |
466
|
|
|
{ |
467
|
|
|
$this->setEnabled(false); |
468
|
|
|
} |
469
|
|
|
|
470
|
|
|
/** |
471
|
|
|
* Set the Google Maps key. |
472
|
|
|
* |
473
|
|
|
* @param string $value |
474
|
|
|
* |
475
|
|
|
* @throws MapperArgumentException |
476
|
|
|
* |
477
|
|
|
* @return void |
478
|
|
|
*/ |
479
|
|
|
public function setKey($value) |
480
|
|
|
{ |
481
|
|
|
if (!is_string($value)) { |
482
|
|
|
throw new MapperArgumentException('Invalid Google Map\'s API key.'); |
483
|
|
|
} |
484
|
|
|
|
485
|
|
|
$this->key = $value; |
486
|
|
|
} |
487
|
|
|
|
488
|
|
|
/** |
489
|
|
|
* Get the Google Maps key. |
490
|
|
|
* |
491
|
|
|
* @return string |
492
|
|
|
*/ |
493
|
|
|
public function getKey() |
494
|
|
|
{ |
495
|
|
|
return $this->key; |
496
|
|
|
} |
497
|
|
|
|
498
|
|
|
/** |
499
|
|
|
* Set the Google Maps version. |
500
|
|
|
* |
501
|
|
|
* @param float|string $value |
502
|
|
|
* |
503
|
|
|
* @throws MapperArgumentException |
504
|
|
|
* |
505
|
|
|
* @return void |
506
|
|
|
*/ |
507
|
|
|
public function setVersion($value) |
508
|
|
|
{ |
509
|
|
|
if (!is_float($value) && !is_string($value)) { |
510
|
|
|
throw new MapperArgumentException('Invalid Google Map\'s API version.'); |
511
|
|
|
} |
512
|
|
|
|
513
|
|
|
$this->version = $value; |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
/** |
517
|
|
|
* Get the Google Maps version. |
518
|
|
|
* |
519
|
|
|
* @return float|string |
520
|
|
|
*/ |
521
|
|
|
public function getVersion() |
522
|
|
|
{ |
523
|
|
|
return $this->version; |
524
|
|
|
} |
525
|
|
|
|
526
|
|
|
/** |
527
|
|
|
* Set the Google Maps region. |
528
|
|
|
* |
529
|
|
|
* @param string $value |
530
|
|
|
* |
531
|
|
|
* @throws MapperArgumentException |
532
|
|
|
* |
533
|
|
|
* @return void |
534
|
|
|
*/ |
535
|
|
|
public function setRegion($value) |
536
|
|
|
{ |
537
|
|
|
if (!is_string($value)) { |
538
|
|
|
throw new MapperArgumentException('Invalid map region.'); |
539
|
|
|
} |
540
|
|
|
|
541
|
|
|
if (!in_array($value, $this->regions)) { |
542
|
|
|
throw new MapperArgumentException('Region is required in ISO 3166-1 code format.'); |
543
|
|
|
} |
544
|
|
|
|
545
|
|
|
$this->region = $value; |
546
|
|
|
} |
547
|
|
|
|
548
|
|
|
/** |
549
|
|
|
* Get the Google Maps region. |
550
|
|
|
* |
551
|
|
|
* @return string |
552
|
|
|
*/ |
553
|
|
|
public function getRegion() |
554
|
|
|
{ |
555
|
|
|
return $this->region; |
556
|
|
|
} |
557
|
|
|
|
558
|
|
|
/** |
559
|
|
|
* Set the Google Maps language. |
560
|
|
|
* |
561
|
|
|
* @param string $value |
562
|
|
|
* |
563
|
|
|
* @throws MapperArgumentException |
564
|
|
|
* |
565
|
|
|
* @return void |
566
|
|
|
*/ |
567
|
|
|
public function setLanguage($value) |
568
|
|
|
{ |
569
|
|
|
if (!is_string($value)) { |
570
|
|
|
throw new MapperArgumentException('Invalid map language.'); |
571
|
|
|
} |
572
|
|
|
|
573
|
|
|
if (!in_array($value, $this->languages)) { |
574
|
|
|
throw new MapperArgumentException('Language is required in ISO 639-1 code format.'); |
575
|
|
|
} |
576
|
|
|
|
577
|
|
|
$this->language = $value; |
578
|
|
|
} |
579
|
|
|
|
580
|
|
|
/** |
581
|
|
|
* Get the Google Maps language. |
582
|
|
|
* |
583
|
|
|
* @return string |
584
|
|
|
*/ |
585
|
|
|
public function getLanguage() |
586
|
|
|
{ |
587
|
|
|
return $this->language; |
588
|
|
|
} |
589
|
|
|
|
590
|
|
|
/** |
591
|
|
|
* Set the map async status. |
592
|
|
|
* |
593
|
|
|
* @param boolean $value |
594
|
|
|
* |
595
|
|
|
* @throws MapperArgumentException |
596
|
|
|
* |
597
|
|
|
* @return void |
598
|
|
|
*/ |
599
|
|
|
protected function setAsync($value) |
600
|
|
|
{ |
601
|
|
|
if (!is_bool($value)) { |
602
|
|
|
throw new MapperArgumentException('Invalid map async status.'); |
603
|
|
|
} |
604
|
|
|
|
605
|
|
|
$this->async = $value; |
606
|
|
|
} |
607
|
|
|
|
608
|
|
|
/** |
609
|
|
|
* Get the map async status. |
610
|
|
|
* |
611
|
|
|
* @return boolean |
612
|
|
|
*/ |
613
|
|
|
public function getAsync() |
614
|
|
|
{ |
615
|
|
|
return $this->async; |
616
|
|
|
} |
617
|
|
|
|
618
|
|
|
/** |
619
|
|
|
* Enable async for maps. |
620
|
|
|
* |
621
|
|
|
* @throws MapperArgumentException |
622
|
|
|
* |
623
|
|
|
* @return void |
624
|
|
|
*/ |
625
|
|
|
public function enableAsync() |
626
|
|
|
{ |
627
|
|
|
$this->setAsync(true); |
628
|
|
|
} |
629
|
|
|
|
630
|
|
|
/** |
631
|
|
|
* Disable async for maps. |
632
|
|
|
* |
633
|
|
|
* @throws MapperArgumentException |
634
|
|
|
* |
635
|
|
|
* @return void |
636
|
|
|
*/ |
637
|
|
|
public function disableAsync() |
638
|
|
|
{ |
639
|
|
|
$this->setAsync(false); |
640
|
|
|
} |
641
|
|
|
|
642
|
|
|
/** |
643
|
|
|
* Set the marker status. |
644
|
|
|
* |
645
|
|
|
* @param boolean $value |
646
|
|
|
* |
647
|
|
|
* @throws MapperArgumentException |
648
|
|
|
* |
649
|
|
|
* @return void |
650
|
|
|
*/ |
651
|
|
|
protected function setMarker($value) |
652
|
|
|
{ |
653
|
|
|
if (!is_bool($value)) { |
654
|
|
|
throw new MapperArgumentException('Invalid map marker setting.'); |
655
|
|
|
} |
656
|
|
|
|
657
|
|
|
$this->marker = $value; |
658
|
|
|
} |
659
|
|
|
|
660
|
|
|
/** |
661
|
|
|
* Get the marker status. |
662
|
|
|
* |
663
|
|
|
* @return boolean |
664
|
|
|
*/ |
665
|
|
|
public function getMarker() |
666
|
|
|
{ |
667
|
|
|
return $this->marker; |
668
|
|
|
} |
669
|
|
|
|
670
|
|
|
/** |
671
|
|
|
* Enable markers for maps. |
672
|
|
|
* |
673
|
|
|
* @throws MapperArgumentException |
674
|
|
|
* |
675
|
|
|
* @return void |
676
|
|
|
*/ |
677
|
|
|
public function enableMarkers() |
678
|
|
|
{ |
679
|
|
|
$this->setMarker(true); |
680
|
|
|
} |
681
|
|
|
|
682
|
|
|
/** |
683
|
|
|
* Disable markers for maps. |
684
|
|
|
* |
685
|
|
|
* @throws MapperArgumentException |
686
|
|
|
* |
687
|
|
|
* @return void |
688
|
|
|
*/ |
689
|
|
|
public function disableMarkers() |
690
|
|
|
{ |
691
|
|
|
$this->setMarker(false); |
692
|
|
|
} |
693
|
|
|
|
694
|
|
|
/** |
695
|
|
|
* Set the map center status. |
696
|
|
|
* |
697
|
|
|
* @param boolean $value |
698
|
|
|
* |
699
|
|
|
* @throws MapperArgumentException |
700
|
|
|
* |
701
|
|
|
* @return void |
702
|
|
|
*/ |
703
|
|
|
protected function setCenter($value) |
704
|
|
|
{ |
705
|
|
|
if (!is_bool($value)) { |
706
|
|
|
throw new MapperArgumentException('Invalid map center setting.'); |
707
|
|
|
} |
708
|
|
|
|
709
|
|
|
$this->center = $value; |
710
|
|
|
} |
711
|
|
|
|
712
|
|
|
/** |
713
|
|
|
* Get the map center status. |
714
|
|
|
* |
715
|
|
|
* @return boolean |
716
|
|
|
*/ |
717
|
|
|
public function getCenter() |
718
|
|
|
{ |
719
|
|
|
return $this->center; |
720
|
|
|
} |
721
|
|
|
|
722
|
|
|
/** |
723
|
|
|
* Enable center of maps. |
724
|
|
|
* |
725
|
|
|
* @throws MapperArgumentException |
726
|
|
|
* |
727
|
|
|
* @return void |
728
|
|
|
*/ |
729
|
|
|
public function enableCenter() |
730
|
|
|
{ |
731
|
|
|
$this->setCenter(true); |
732
|
|
|
} |
733
|
|
|
|
734
|
|
|
/** |
735
|
|
|
* Disable center of maps. |
736
|
|
|
* |
737
|
|
|
* @throws MapperArgumentException |
738
|
|
|
* |
739
|
|
|
* @return void |
740
|
|
|
*/ |
741
|
|
|
public function disableCenter() |
742
|
|
|
{ |
743
|
|
|
$this->setCenter(false); |
744
|
|
|
} |
745
|
|
|
|
746
|
|
|
/** |
747
|
|
|
* Set the map locate user status. |
748
|
|
|
* |
749
|
|
|
* @param boolean $value |
750
|
|
|
* |
751
|
|
|
* @throws MapperArgumentException |
752
|
|
|
* |
753
|
|
|
* @return void |
754
|
|
|
*/ |
755
|
|
|
protected function setLocate($value) |
756
|
|
|
{ |
757
|
|
|
if (!is_bool($value)) { |
758
|
|
|
throw new MapperArgumentException('Invalid map locate setting.'); |
759
|
|
|
} |
760
|
|
|
|
761
|
|
|
$this->locate = $value; |
762
|
|
|
} |
763
|
|
|
|
764
|
|
|
/** |
765
|
|
|
* Get the map locate user status. |
766
|
|
|
* |
767
|
|
|
* @return boolean |
768
|
|
|
*/ |
769
|
|
|
public function getLocate() |
770
|
|
|
{ |
771
|
|
|
return $this->locate; |
772
|
|
|
} |
773
|
|
|
|
774
|
|
|
/** |
775
|
|
|
* Enable locate user position on maps. |
776
|
|
|
* |
777
|
|
|
* @throws MapperArgumentException |
778
|
|
|
* |
779
|
|
|
* @return void |
780
|
|
|
*/ |
781
|
|
|
public function enableLocate() |
782
|
|
|
{ |
783
|
|
|
$this->setLocate(true); |
784
|
|
|
} |
785
|
|
|
|
786
|
|
|
/** |
787
|
|
|
* Disable locate user position on maps. |
788
|
|
|
* |
789
|
|
|
* @throws MapperArgumentException |
790
|
|
|
* |
791
|
|
|
* @return void |
792
|
|
|
*/ |
793
|
|
|
public function disableLocate() |
794
|
|
|
{ |
795
|
|
|
$this->setLocate(false); |
796
|
|
|
} |
797
|
|
|
|
798
|
|
|
/** |
799
|
|
|
* Set the map UI status. |
800
|
|
|
* |
801
|
|
|
* @param boolean $value |
802
|
|
|
* |
803
|
|
|
* @throws MapperArgumentException |
804
|
|
|
* |
805
|
|
|
* @return void |
806
|
|
|
*/ |
807
|
|
|
protected function setUi($value) |
808
|
|
|
{ |
809
|
|
|
if (!is_bool($value)) { |
810
|
|
|
throw new MapperArgumentException('Invalid map ui setting.'); |
811
|
|
|
} |
812
|
|
|
|
813
|
|
|
$this->ui = $value; |
814
|
|
|
} |
815
|
|
|
|
816
|
|
|
/** |
817
|
|
|
* Get the map UI status. |
818
|
|
|
* |
819
|
|
|
* @return boolean |
820
|
|
|
*/ |
821
|
|
|
public function getUi() |
822
|
|
|
{ |
823
|
|
|
return $this->ui; |
824
|
|
|
} |
825
|
|
|
|
826
|
|
|
/** |
827
|
|
|
* Enable maps ui. |
828
|
|
|
* |
829
|
|
|
* @throws MapperArgumentException |
830
|
|
|
* |
831
|
|
|
* @return void |
832
|
|
|
*/ |
833
|
|
|
public function enableUi() |
834
|
|
|
{ |
835
|
|
|
$this->setUi(false); |
836
|
|
|
} |
837
|
|
|
|
838
|
|
|
/** |
839
|
|
|
* Disable maps ui. |
840
|
|
|
* |
841
|
|
|
* @throws MapperArgumentException |
842
|
|
|
* |
843
|
|
|
* @return void |
844
|
|
|
*/ |
845
|
|
|
public function disableUi() |
846
|
|
|
{ |
847
|
|
|
$this->setUi(true); |
848
|
|
|
} |
849
|
|
|
|
850
|
|
|
/** |
851
|
|
|
* Set map zoom level. |
852
|
|
|
* |
853
|
|
|
* @param int $value |
854
|
|
|
* |
855
|
|
|
* @throws MapperArgumentException |
856
|
|
|
* |
857
|
|
|
* @return void |
858
|
|
|
*/ |
859
|
|
|
public function setZoom($value) |
860
|
|
|
{ |
861
|
|
|
if (!is_numeric($value)) { |
862
|
|
|
throw new MapperArgumentException('Zoom level must be an integer.'); |
863
|
|
|
} |
864
|
|
|
|
865
|
|
|
if ($value < 1 || $value > 20) { |
866
|
|
|
throw new MapperArgumentException('A zoom level must be between 1 and 20.'); |
867
|
|
|
} |
868
|
|
|
|
869
|
|
|
$this->zoom = $value; |
|
|
|
|
870
|
|
|
} |
871
|
|
|
|
872
|
|
|
/** |
873
|
|
|
* Get map zoom level. |
874
|
|
|
* |
875
|
|
|
* @return int |
876
|
|
|
*/ |
877
|
|
|
public function getZoom() |
878
|
|
|
{ |
879
|
|
|
return $this->zoom; |
880
|
|
|
} |
881
|
|
|
|
882
|
|
|
/** |
883
|
|
|
* Set map scroll wheel zoom. |
884
|
|
|
* |
885
|
|
|
* @param boolean $value |
886
|
|
|
* |
887
|
|
|
* @throws MapperArgumentException |
888
|
|
|
* |
889
|
|
|
* @return void |
890
|
|
|
*/ |
891
|
|
|
public function setScrollWheelZoom($value) |
892
|
|
|
{ |
893
|
|
|
if (!is_bool($value)) { |
894
|
|
|
throw new MapperArgumentException('Mouse Wheel Zoom must be a boolean.'); |
895
|
|
|
} |
896
|
|
|
|
897
|
|
|
$this->scrollWheelZoom = $value; |
898
|
|
|
} |
899
|
|
|
|
900
|
|
|
/** |
901
|
|
|
* Get map scroll wheel zoom. |
902
|
|
|
* |
903
|
|
|
* @return boolean |
904
|
|
|
*/ |
905
|
|
|
public function getScrollWheelZoom() |
906
|
|
|
{ |
907
|
|
|
return $this->scrollWheelZoom; |
908
|
|
|
} |
909
|
|
|
|
910
|
|
|
/** |
911
|
|
|
* Set map zoom control. |
912
|
|
|
* |
913
|
|
|
* @param boolean $value |
914
|
|
|
* |
915
|
|
|
* @throws MapperArgumentException |
916
|
|
|
* |
917
|
|
|
* @return void |
918
|
|
|
*/ |
919
|
|
|
public function setZoomControl($value) |
920
|
|
|
{ |
921
|
|
|
if (!is_bool($value)) { |
922
|
|
|
throw new MapperArgumentException('Zoom control must be a boolean.'); |
923
|
|
|
} |
924
|
|
|
|
925
|
|
|
$this->zoomControl = $value; |
926
|
|
|
} |
927
|
|
|
|
928
|
|
|
/** |
929
|
|
|
* Get map zoom control. |
930
|
|
|
* |
931
|
|
|
* @return boolean |
932
|
|
|
*/ |
933
|
|
|
public function getZoomControl() |
934
|
|
|
{ |
935
|
|
|
return $this->zoomControl; |
936
|
|
|
} |
937
|
|
|
|
938
|
|
|
/** |
939
|
|
|
* Set map type control. |
940
|
|
|
* |
941
|
|
|
* @param boolean $value |
942
|
|
|
* |
943
|
|
|
* @throws MapperArgumentException |
944
|
|
|
* |
945
|
|
|
* @return void |
946
|
|
|
*/ |
947
|
|
|
public function setMapTypeControl($value) |
948
|
|
|
{ |
949
|
|
|
if (!is_bool($value)) { |
950
|
|
|
throw new MapperArgumentException('Map type control must be a boolean.'); |
951
|
|
|
} |
952
|
|
|
|
953
|
|
|
$this->mapTypeControl = $value; |
954
|
|
|
} |
955
|
|
|
|
956
|
|
|
/** |
957
|
|
|
* Get map type control. |
958
|
|
|
* |
959
|
|
|
* @return boolean |
960
|
|
|
*/ |
961
|
|
|
public function getMapTypeControl() |
962
|
|
|
{ |
963
|
|
|
return $this->mapTypeControl; |
964
|
|
|
} |
965
|
|
|
|
966
|
|
|
/** |
967
|
|
|
* Set map scale control. |
968
|
|
|
* |
969
|
|
|
* @param boolean $value |
970
|
|
|
* |
971
|
|
|
* @throws MapperArgumentException |
972
|
|
|
* |
973
|
|
|
* @return void |
974
|
|
|
*/ |
975
|
|
|
public function setScaleControl($value) |
976
|
|
|
{ |
977
|
|
|
if (!is_bool($value)) { |
978
|
|
|
throw new MapperArgumentException('Scale control must be a boolean.'); |
979
|
|
|
} |
980
|
|
|
|
981
|
|
|
$this->scaleControl = $value; |
982
|
|
|
} |
983
|
|
|
|
984
|
|
|
/** |
985
|
|
|
* Get map scale control. |
986
|
|
|
* |
987
|
|
|
* @return boolean |
988
|
|
|
*/ |
989
|
|
|
public function getScaleControl() |
990
|
|
|
{ |
991
|
|
|
return $this->scaleControl; |
992
|
|
|
} |
993
|
|
|
|
994
|
|
|
/** |
995
|
|
|
* Set map street view control. |
996
|
|
|
* |
997
|
|
|
* @param boolean $value |
998
|
|
|
* |
999
|
|
|
* @throws MapperArgumentException |
1000
|
|
|
* |
1001
|
|
|
* @return void |
1002
|
|
|
*/ |
1003
|
|
|
public function setStreetViewControl($value) |
1004
|
|
|
{ |
1005
|
|
|
if (!is_bool($value)) { |
1006
|
|
|
throw new MapperArgumentException('Street view control must be a boolean.'); |
1007
|
|
|
} |
1008
|
|
|
|
1009
|
|
|
$this->streetViewControl = $value; |
1010
|
|
|
} |
1011
|
|
|
|
1012
|
|
|
/** |
1013
|
|
|
* Get map street view control. |
1014
|
|
|
* |
1015
|
|
|
* @return boolean |
1016
|
|
|
*/ |
1017
|
|
|
public function getStreetViewControl() |
1018
|
|
|
{ |
1019
|
|
|
return $this->streetViewControl; |
1020
|
|
|
} |
1021
|
|
|
|
1022
|
|
|
/** |
1023
|
|
|
* Set map rotate control. |
1024
|
|
|
* |
1025
|
|
|
* @param boolean $value |
1026
|
|
|
* |
1027
|
|
|
* @throws MapperArgumentException |
1028
|
|
|
* |
1029
|
|
|
* @return void |
1030
|
|
|
*/ |
1031
|
|
|
public function setRotateControl($value) |
1032
|
|
|
{ |
1033
|
|
|
if (!is_bool($value)) { |
1034
|
|
|
throw new MapperArgumentException('Rotate control must be a boolean.'); |
1035
|
|
|
} |
1036
|
|
|
|
1037
|
|
|
$this->rotateControl = $value; |
1038
|
|
|
} |
1039
|
|
|
|
1040
|
|
|
/** |
1041
|
|
|
* Get map rotate control. |
1042
|
|
|
* |
1043
|
|
|
* @return boolean |
1044
|
|
|
*/ |
1045
|
|
|
public function getRotateControl() |
1046
|
|
|
{ |
1047
|
|
|
return $this->rotateControl; |
1048
|
|
|
} |
1049
|
|
|
|
1050
|
|
|
/** |
1051
|
|
|
* Set map fullscreen control. |
1052
|
|
|
* |
1053
|
|
|
* @param boolean $value |
1054
|
|
|
* |
1055
|
|
|
* @throws MapperArgumentException |
1056
|
|
|
* |
1057
|
|
|
* @return void |
1058
|
|
|
*/ |
1059
|
|
|
public function setFullscreenControl($value) |
1060
|
|
|
{ |
1061
|
|
|
if (!is_bool($value)) { |
1062
|
|
|
throw new MapperArgumentException('Fullscreen control must be a boolean.'); |
1063
|
|
|
} |
1064
|
|
|
|
1065
|
|
|
$this->fullscreenControl = $value; |
1066
|
|
|
} |
1067
|
|
|
|
1068
|
|
|
/** |
1069
|
|
|
* Get map fullscreen control. |
1070
|
|
|
* |
1071
|
|
|
* @return boolean |
1072
|
|
|
*/ |
1073
|
|
|
public function getFullscreenControl() |
1074
|
|
|
{ |
1075
|
|
|
return $this->fullscreenControl; |
1076
|
|
|
} |
1077
|
|
|
|
1078
|
|
|
/** |
1079
|
|
|
* Set map type. |
1080
|
|
|
* |
1081
|
|
|
* @param string $value |
1082
|
|
|
* |
1083
|
|
|
* @throws MapperArgumentException |
1084
|
|
|
* |
1085
|
|
|
* @return void |
1086
|
|
|
*/ |
1087
|
|
|
public function setType($value) |
1088
|
|
|
{ |
1089
|
|
|
if (!in_array($value, $this->types)) { |
1090
|
|
|
throw new MapperArgumentException('Invalid map type.'); |
1091
|
|
|
} |
1092
|
|
|
|
1093
|
|
|
$this->type = $value; |
1094
|
|
|
} |
1095
|
|
|
|
1096
|
|
|
/** |
1097
|
|
|
* Get map type. |
1098
|
|
|
* |
1099
|
|
|
* @return string |
1100
|
|
|
*/ |
1101
|
|
|
public function getType() |
1102
|
|
|
{ |
1103
|
|
|
return $this->type; |
1104
|
|
|
} |
1105
|
|
|
|
1106
|
|
|
/** |
1107
|
|
|
* Set map heading. |
1108
|
|
|
* |
1109
|
|
|
* @param int|double $value |
1110
|
|
|
* |
1111
|
|
|
* @throws MapperArgumentException |
1112
|
|
|
* |
1113
|
|
|
* @return void |
1114
|
|
|
*/ |
1115
|
|
|
public function setHeading($value) |
1116
|
|
|
{ |
1117
|
|
|
if (!is_numeric($value)) { |
1118
|
|
|
throw new MapperArgumentException('Invalid map heading.'); |
1119
|
|
|
} |
1120
|
|
|
|
1121
|
|
|
$this->heading = $value; |
|
|
|
|
1122
|
|
|
} |
1123
|
|
|
|
1124
|
|
|
/** |
1125
|
|
|
* Get map heading. |
1126
|
|
|
* |
1127
|
|
|
* @return int|double |
1128
|
|
|
*/ |
1129
|
|
|
public function getHeading() |
1130
|
|
|
{ |
1131
|
|
|
return $this->heading; |
1132
|
|
|
} |
1133
|
|
|
|
1134
|
|
|
/** |
1135
|
|
|
* Set map tilt. |
1136
|
|
|
* |
1137
|
|
|
* @param int|double $value |
1138
|
|
|
* |
1139
|
|
|
* @throws MapperArgumentException |
1140
|
|
|
* |
1141
|
|
|
* @return void |
1142
|
|
|
*/ |
1143
|
|
|
public function setTilt($value) |
1144
|
|
|
{ |
1145
|
|
|
if (!is_numeric($value)) { |
1146
|
|
|
throw new MapperArgumentException('Invalid map tilt.'); |
1147
|
|
|
} |
1148
|
|
|
|
1149
|
|
|
$this->tilt = $value; |
|
|
|
|
1150
|
|
|
} |
1151
|
|
|
|
1152
|
|
|
/** |
1153
|
|
|
* Get map tilt. |
1154
|
|
|
* |
1155
|
|
|
* @return int |
1156
|
|
|
*/ |
1157
|
|
|
public function getTilt() |
1158
|
|
|
{ |
1159
|
|
|
return $this->tilt; |
1160
|
|
|
} |
1161
|
|
|
|
1162
|
|
|
/** |
1163
|
|
|
* Set map marker icon. |
1164
|
|
|
* |
1165
|
|
|
* @param string $value |
1166
|
|
|
* |
1167
|
|
|
* @throws MapperArgumentException |
1168
|
|
|
* |
1169
|
|
|
* @return void |
1170
|
|
|
*/ |
1171
|
|
|
public function setIcon($value) |
1172
|
|
|
{ |
1173
|
|
|
if (!is_string($value)) { |
1174
|
|
|
throw new MapperArgumentException('Invalid map marker icon.'); |
1175
|
|
|
} |
1176
|
|
|
|
1177
|
|
|
$this->icon = $value; |
1178
|
|
|
} |
1179
|
|
|
|
1180
|
|
|
/** |
1181
|
|
|
* Get map marker icon. |
1182
|
|
|
* |
1183
|
|
|
* @return string |
1184
|
|
|
*/ |
1185
|
|
|
public function getIcon() |
1186
|
|
|
{ |
1187
|
|
|
return $this->icon; |
1188
|
|
|
} |
1189
|
|
|
|
1190
|
|
|
/** |
1191
|
|
|
* Set map marker animation. |
1192
|
|
|
* |
1193
|
|
|
* @param string $value |
1194
|
|
|
* |
1195
|
|
|
* @throws MapperArgumentException |
1196
|
|
|
* |
1197
|
|
|
* @return void |
1198
|
|
|
*/ |
1199
|
|
|
public function setAnimation($value) |
1200
|
|
|
{ |
1201
|
|
|
if (!in_array($value, $this->animations)) { |
1202
|
|
|
throw new MapperArgumentException('Invalid map marker animation.'); |
1203
|
|
|
} |
1204
|
|
|
|
1205
|
|
|
$this->animation = $value; |
1206
|
|
|
} |
1207
|
|
|
|
1208
|
|
|
/** |
1209
|
|
|
* Get map marker animation. |
1210
|
|
|
* |
1211
|
|
|
* @return string |
1212
|
|
|
*/ |
1213
|
|
|
public function getAnimation() |
1214
|
|
|
{ |
1215
|
|
|
return $this->animation; |
1216
|
|
|
} |
1217
|
|
|
|
1218
|
|
|
/** |
1219
|
|
|
* Set map gesture handling. |
1220
|
|
|
* |
1221
|
|
|
* @param string $value |
1222
|
|
|
* |
1223
|
|
|
* @throws MapperArgumentException |
1224
|
|
|
* |
1225
|
|
|
* @return void |
1226
|
|
|
*/ |
1227
|
|
|
public function setGestureHandling($value) |
1228
|
|
|
{ |
1229
|
|
|
if (!in_array($value, $this->gestureHandlers)) { |
1230
|
|
|
throw new MapperArgumentException('Invalid map gesture handling.'); |
1231
|
|
|
} |
1232
|
|
|
|
1233
|
|
|
$this->gestureHandling = $value; |
1234
|
|
|
} |
1235
|
|
|
|
1236
|
|
|
/** |
1237
|
|
|
* Get map gesture handling. |
1238
|
|
|
* |
1239
|
|
|
* @return string |
1240
|
|
|
*/ |
1241
|
|
|
public function getGestureHandling() |
1242
|
|
|
{ |
1243
|
|
|
return $this->gestureHandling; |
1244
|
|
|
} |
1245
|
|
|
|
1246
|
|
|
/** |
1247
|
|
|
* Set cluster status. |
1248
|
|
|
* |
1249
|
|
|
* @param bool $value |
1250
|
|
|
* |
1251
|
|
|
* @throws MapperArgumentException |
1252
|
|
|
* |
1253
|
|
|
* @return void |
1254
|
|
|
*/ |
1255
|
|
|
protected function setCluster($value) |
1256
|
|
|
{ |
1257
|
|
|
if (!is_bool($value)) { |
1258
|
|
|
throw new MapperArgumentException('Invalid map cluster setting.'); |
1259
|
|
|
} |
1260
|
|
|
|
1261
|
|
|
$this->cluster = $value; |
1262
|
|
|
} |
1263
|
|
|
|
1264
|
|
|
/** |
1265
|
|
|
* Get the cluster status. |
1266
|
|
|
* |
1267
|
|
|
* @return bool |
1268
|
|
|
*/ |
1269
|
|
|
public function getCluster() |
1270
|
|
|
{ |
1271
|
|
|
return $this->cluster; |
1272
|
|
|
} |
1273
|
|
|
|
1274
|
|
|
/** |
1275
|
|
|
* Enable cluster. |
1276
|
|
|
* |
1277
|
|
|
* @throws MapperArgumentException |
1278
|
|
|
* |
1279
|
|
|
* @return void |
1280
|
|
|
*/ |
1281
|
|
|
public function enableCluster() |
1282
|
|
|
{ |
1283
|
|
|
$this->setCluster(true); |
1284
|
|
|
} |
1285
|
|
|
|
1286
|
|
|
/** |
1287
|
|
|
* Disable cluster. |
1288
|
|
|
* |
1289
|
|
|
* @throws MapperArgumentException |
1290
|
|
|
* |
1291
|
|
|
* @return void |
1292
|
|
|
*/ |
1293
|
|
|
public function disableCluster() |
1294
|
|
|
{ |
1295
|
|
|
$this->setCluster(false); |
1296
|
|
|
} |
1297
|
|
|
|
1298
|
|
|
/** |
1299
|
|
|
* Set map cluster icon. |
1300
|
|
|
* |
1301
|
|
|
* @param string $value |
1302
|
|
|
* |
1303
|
|
|
* @throws MapperArgumentException |
1304
|
|
|
* |
1305
|
|
|
* @return void |
1306
|
|
|
*/ |
1307
|
|
|
public function setClustersIcon($value) |
1308
|
|
|
{ |
1309
|
|
|
if (!is_string($value)) { |
1310
|
|
|
throw new MapperArgumentException('Invalid map clusters icon setting.'); |
1311
|
|
|
} |
1312
|
|
|
|
1313
|
|
|
$this->clustersIcon = $value; |
1314
|
|
|
} |
1315
|
|
|
|
1316
|
|
|
/** |
1317
|
|
|
* Get map clusters icon. |
1318
|
|
|
* |
1319
|
|
|
* @return string |
1320
|
|
|
*/ |
1321
|
|
|
public function getClustersIcon() |
1322
|
|
|
{ |
1323
|
|
|
return $this->clustersIcon; |
1324
|
|
|
} |
1325
|
|
|
|
1326
|
|
|
/** |
1327
|
|
|
* Set map cluster grid. |
1328
|
|
|
* |
1329
|
|
|
* @param int $value |
1330
|
|
|
* |
1331
|
|
|
* @throws MapperArgumentException |
1332
|
|
|
* |
1333
|
|
|
* @return void |
1334
|
|
|
*/ |
1335
|
|
|
public function setClustersGrid($value) |
1336
|
|
|
{ |
1337
|
|
|
if (!is_int($value)) { |
1338
|
|
|
throw new MapperArgumentException('Invalid map clusters grid setting.'); |
1339
|
|
|
} |
1340
|
|
|
|
1341
|
|
|
$this->clustersGrid = $value; |
1342
|
|
|
} |
1343
|
|
|
|
1344
|
|
|
/** |
1345
|
|
|
* Get map cluster grid. |
1346
|
|
|
* |
1347
|
|
|
* @return int |
1348
|
|
|
*/ |
1349
|
|
|
public function getClustersGrid() |
1350
|
|
|
{ |
1351
|
|
|
return $this->clustersGrid; |
1352
|
|
|
} |
1353
|
|
|
|
1354
|
|
|
/** |
1355
|
|
|
* Set map cluster zoom. |
1356
|
|
|
* |
1357
|
|
|
* @param int|null $value |
1358
|
|
|
* |
1359
|
|
|
* @throws MapperArgumentException |
1360
|
|
|
* |
1361
|
|
|
* @return void |
1362
|
|
|
*/ |
1363
|
|
|
public function setClustersZoom($value) |
1364
|
|
|
{ |
1365
|
|
|
if (!is_integer($value) && !is_null($value)) { |
1366
|
|
|
throw new MapperArgumentException('Invalid map clusters zoom setting.'); |
1367
|
|
|
} |
1368
|
|
|
|
1369
|
|
|
$this->clustersZoom = $value; |
1370
|
|
|
} |
1371
|
|
|
|
1372
|
|
|
/** |
1373
|
|
|
* Get map cluster grid. |
1374
|
|
|
* |
1375
|
|
|
* @return integer|null |
1376
|
|
|
*/ |
1377
|
|
|
public function getClustersZoom() |
1378
|
|
|
{ |
1379
|
|
|
return $this->clustersZoom; |
1380
|
|
|
} |
1381
|
|
|
|
1382
|
|
|
/** |
1383
|
|
|
* Set map cluster center. |
1384
|
|
|
* |
1385
|
|
|
* @param bool $value |
1386
|
|
|
* |
1387
|
|
|
* @throws MapperArgumentException |
1388
|
|
|
* |
1389
|
|
|
* @return void |
1390
|
|
|
*/ |
1391
|
|
|
public function setClustersCenter($value) |
1392
|
|
|
{ |
1393
|
|
|
if (!is_bool($value)) { |
1394
|
|
|
throw new MapperArgumentException('Invalid map clusters center setting.'); |
1395
|
|
|
} |
1396
|
|
|
|
1397
|
|
|
$this->clustersCenter = $value; |
1398
|
|
|
} |
1399
|
|
|
|
1400
|
|
|
/** |
1401
|
|
|
* Get map cluster center. |
1402
|
|
|
* |
1403
|
|
|
* @return bool |
1404
|
|
|
*/ |
1405
|
|
|
public function getClustersCenter() |
1406
|
|
|
{ |
1407
|
|
|
return $this->clustersCenter; |
1408
|
|
|
} |
1409
|
|
|
|
1410
|
|
|
/** |
1411
|
|
|
* Set map cluster size. |
1412
|
|
|
* |
1413
|
|
|
* @param int $value |
1414
|
|
|
* |
1415
|
|
|
* @throws MapperArgumentException |
1416
|
|
|
* |
1417
|
|
|
* @return void |
1418
|
|
|
*/ |
1419
|
|
|
public function setClustersSize($value) |
1420
|
|
|
{ |
1421
|
|
|
if (!is_integer($value)) { |
1422
|
|
|
throw new MapperArgumentException('Invalid map clusters size setting.'); |
1423
|
|
|
} |
1424
|
|
|
|
1425
|
|
|
$this->clustersSize = $value; |
1426
|
|
|
} |
1427
|
|
|
|
1428
|
|
|
/** |
1429
|
|
|
* Get map cluster size. |
1430
|
|
|
* |
1431
|
|
|
* @return int |
1432
|
|
|
*/ |
1433
|
|
|
public function getClustersSize() |
1434
|
|
|
{ |
1435
|
|
|
return $this->clustersSize; |
1436
|
|
|
} |
1437
|
|
|
|
1438
|
|
|
/** |
1439
|
|
|
* Get mapper options. |
1440
|
|
|
* |
1441
|
|
|
* @return array |
1442
|
|
|
*/ |
1443
|
|
|
protected function getOptions() |
1444
|
|
|
{ |
1445
|
|
|
return [ |
1446
|
|
|
'key' => $this->getKey(), |
1447
|
|
|
'version' => $this->getVersion(), |
1448
|
|
|
'region' => $this->getRegion(), |
1449
|
|
|
'language' => $this->getLanguage(), |
1450
|
|
|
'async' => $this->getAsync(), |
1451
|
|
|
'marker' => $this->getMarker(), |
1452
|
|
|
'center' => $this->getCenter(), |
1453
|
|
|
'locate' => $this->getLocate(), |
1454
|
|
|
'zoom' => $this->getZoom(), |
1455
|
|
|
'scrollWheelZoom' => $this->getScrollWheelZoom(), |
1456
|
|
|
'fullscreenControl' => $this->getFullscreenControl(), |
1457
|
|
|
'zoomControl' => $this->getZoomControl(), |
1458
|
|
|
'scaleControl' => $this->getScaleControl(), |
1459
|
|
|
'streetViewControl' => $this->getStreetViewControl(), |
1460
|
|
|
'rotateControl' => $this->getRotateControl(), |
1461
|
|
|
'mapTypeControl' => $this->getMapTypeControl(), |
1462
|
|
|
'type' => $this->getType(), |
1463
|
|
|
'heading' => $this->getHeading(), |
1464
|
|
|
'tilt' => $this->getTilt(), |
1465
|
|
|
'ui' => $this->getUi(), |
1466
|
|
|
'overlay' => '', |
1467
|
|
|
'gestureHandling' => $this->getGestureHandling(), |
1468
|
|
|
'markers' => [ |
1469
|
|
|
'title' => '', |
1470
|
|
|
'label' => '', |
1471
|
|
|
'content' => '', |
1472
|
|
|
'icon' => $this->getIcon(), |
1473
|
|
|
'place' => '', |
1474
|
|
|
'animation' => $this->getAnimation(), |
1475
|
|
|
'symbol' => '', |
1476
|
|
|
], |
1477
|
|
|
'cluster' => $this->getCluster(), |
1478
|
|
|
'clusters' => [ |
1479
|
|
|
'icon' => $this->getClustersIcon(), |
1480
|
|
|
'grid' => $this->getClustersGrid(), |
1481
|
|
|
'zoom' => $this->getClustersZoom(), |
1482
|
|
|
'center' => $this->getClustersCenter(), |
1483
|
|
|
'size' => $this->getClustersSize() |
1484
|
|
|
], |
1485
|
|
|
]; |
1486
|
|
|
} |
1487
|
|
|
|
1488
|
|
|
/** |
1489
|
|
|
* Add mapping item. |
1490
|
|
|
* |
1491
|
|
|
* @param object $value |
1492
|
|
|
* |
1493
|
|
|
* @return void |
1494
|
|
|
*/ |
1495
|
|
|
protected function addItem($value) |
1496
|
|
|
{ |
1497
|
|
|
$this->items[] = $value; |
1498
|
|
|
} |
1499
|
|
|
|
1500
|
|
|
/** |
1501
|
|
|
* Set mapping items. |
1502
|
|
|
* |
1503
|
|
|
* @param array $array |
1504
|
|
|
* |
1505
|
|
|
* @return void |
1506
|
|
|
*/ |
1507
|
|
|
protected function setItems(array $array) |
1508
|
|
|
{ |
1509
|
|
|
$this->items = $array; |
1510
|
|
|
} |
1511
|
|
|
|
1512
|
|
|
/** |
1513
|
|
|
* Get the mapping items. |
1514
|
|
|
* |
1515
|
|
|
* @return array |
1516
|
|
|
*/ |
1517
|
|
|
public function getItems() |
1518
|
|
|
{ |
1519
|
|
|
return $this->items; |
1520
|
|
|
} |
1521
|
|
|
|
1522
|
|
|
/** |
1523
|
|
|
* Get a mapping item by reference. |
1524
|
|
|
* |
1525
|
|
|
* @param int $item |
1526
|
|
|
* |
1527
|
|
|
* @return array|bool |
1528
|
|
|
*/ |
1529
|
|
|
public function getItem($item) |
1530
|
|
|
{ |
1531
|
|
|
return isset($this->items[$item]) ? $this->items[$item] : false; |
1532
|
|
|
} |
1533
|
|
|
} |
1534
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.