1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Ivory Google Map package. |
7
|
|
|
* |
8
|
|
|
* (c) Eric GELOEN <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please read the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Ivory\GoogleMap\Helper\Renderer\Image\Overlay; |
15
|
|
|
|
16
|
|
|
use Ivory\GoogleMap\Base\Coordinate; |
17
|
|
|
use Ivory\GoogleMap\Helper\Renderer\Image\Base\CoordinateRenderer; |
18
|
|
|
use Ivory\GoogleMap\Overlay\Marker; |
19
|
|
|
use Ivory\GoogleMap\Overlay\Polyline; |
20
|
|
|
|
21
|
|
|
class ExtendableRenderer |
22
|
|
|
{ |
23
|
|
|
/** @var CoordinateRenderer */ |
24
|
|
|
private $coordinateRenderer; |
25
|
|
|
|
26
|
|
|
/** @var MarkerLocationRenderer */ |
27
|
|
|
private $markerLocationRenderer; |
28
|
|
|
|
29
|
|
|
/** @var PolylineLocationRenderer */ |
30
|
|
|
private $polylineLocationRenderer; |
31
|
|
|
|
32
|
1 |
|
public function __construct( |
33
|
|
|
CoordinateRenderer $coordinateRenderer, |
34
|
|
|
MarkerLocationRenderer $markerLocationRenderer, |
35
|
|
|
PolylineLocationRenderer $polylineLocationRenderer |
36
|
|
|
) { |
37
|
1 |
|
$this->coordinateRenderer = $coordinateRenderer; |
38
|
1 |
|
$this->markerLocationRenderer = $markerLocationRenderer; |
39
|
1 |
|
$this->polylineLocationRenderer = $polylineLocationRenderer; |
40
|
1 |
|
} |
41
|
|
|
|
42
|
|
|
public function render(array $extendables): string |
43
|
|
|
{ |
44
|
|
|
$result = []; |
45
|
|
|
|
46
|
|
|
foreach ($extendables as $value) { |
47
|
|
|
if ($value instanceof Coordinate) { |
48
|
|
|
$result[] = $this->coordinateRenderer->render($value); |
49
|
|
|
} elseif ($value instanceof Marker) { |
50
|
|
|
$result[] = $this->markerLocationRenderer->render($value); |
51
|
|
|
} elseif ($value instanceof Polyline) { |
52
|
|
|
$result[] = $this->polylineLocationRenderer->render($value); |
53
|
|
|
} else { |
54
|
|
|
$result[] = $value; |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
return implode('|', $result); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|