This repository has been archived by the owner on Jul 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
/
PolygonOptions.php
126 lines (116 loc) · 4.34 KB
/
PolygonOptions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
/*
*
* @copyright Copyright (c) 2013-2019 2amigos
* @link http://2amigos.us
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
*
*/
namespace dosamigos\google\maps\overlays;
use dosamigos\google\maps\LatLng;
use dosamigos\google\maps\ObjectAbstract;
use dosamigos\google\maps\OptionsTrait;
use yii\helpers\ArrayHelper;
use yii\web\JsExpression;
/**
* PolygonOptions
*
* Eases the configuration of a polygon or polygons
*
* @property boolean $clickable Indicates whether this Polygon handles mouse events. Defaults to true.
* @property boolean $draggable If set to true, the user can drag this shape over the map. The geodesic property defines
* the mode of dragging. Defaults to false.
* @property boolean $editable If set to true, the user can edit this shape by dragging the control points shown at the
* vertices and on each segment. Defaults to false.
* @property string $fillColor The fill color. All CSS3 colors are supported except for extended named colors.
* @property int $fillOpacity The fill opacity between 0.0 and 1.0
* @property boolean $geodesic When true, edges of the polygon are interpreted as geodesic and will follow the curvature
* of the Earth. When false, edges of the polygon are rendered as straight lines in screen space. Note that the shape
* of a geodesic polygon may appear to change when dragged, as the dimensions are maintained relative to the surface of
* the earth. Defaults to false.
* @property string $map Map name on which to display Polygon.
* @property LatLng[] $paths The ordered sequence of coordinates that designates a closed loop. Unlike polylines, a
* polygon may consist of one or more paths. As a result, the paths property may specify one or more arrays of LatLng
* coordinates. Paths are closed automatically; do not repeat the first vertex of the path as the last vertex. Simple
* polygons may be defined using a single array of LatLngs. More complex polygons may specify an array of arrays. Any
* simple arrays are converted into MVCArrays. Inserting or removing LatLngs from the MVCArray will automatically update
* the polygon on the map.
* @propperty string $strokeColor The stroke color. All CSS3 colors are supported except for extended named colors.
* @property int $strokeOpacity The stroke opacity between 0.0 and 1.0
* @property string $strokePosition The stroke position. Defaults to [StrokePosition::CENTER]. This property is not
* supported on Internet Explorer 8 and earlier.
* @property int $strokeWeight The stroke width in pixels.
* @property boolean $visible Whether this polygon is visible on the map. Defaults to true.
* @property int $zIndex The zIndex compared to other polygones.
*
* @author Antonio Ramirez <hola@2amigos.us>
*
* @link http://www.2amigos.us/
* @package dosamigos\google\maps
*/
class PolygonOptions extends ObjectAbstract
{
use OptionsTrait;
/**
* @inheritdoc
*
* @param array $config
*/
public function __construct($config = [])
{
$this->options = ArrayHelper::merge(
[
'clickable' => null,
'draggable' => null,
'editable' => null,
'fillColor' => null,
'fillOpacity' => null,
'geodesic' => null,
'map' => null,
'paths' => [],
'strokeColor' => null,
'strokeOpacity' => null,
'strokePosition' => null,
'strokeWeight' => null,
'visible' => null,
'zIndex' => null,
],
$this->options
);
parent::__construct($config);
}
/**
* Sets the map option property.
*
* @param string $value
*/
public function setMap($value)
{
$this->options['map'] = new JsExpression($value);
}
/**
* Adds a coordinate to the path array
*
* @param LatLng $coord
*
* @return $this
*/
public function addCoord(LatLng $coord)
{
$cloned = clone $coord;
$cloned->name = null;
$this->options['paths'][] = $coord;
return $this;
}
/**
* Sets the path of the polygon
*
* @param array $coords
*/
public function setPaths(array $coords)
{
foreach ($coords as $coord) {
$this->addCoord($coord);
}
}
}