@@ -103,21 +103,22 @@ public function addPolygon(Polygon $polygon): self
103
103
public function addPolyline (Polyline $ polyline ): self
104
104
{
105
105
$ this ->polylines [] = $ polyline ;
106
+
106
107
return $ this ;
107
108
}
108
-
109
+
109
110
public function toArray (): array
110
111
{
111
112
if (!$ this ->fitBoundsToMarkers ) {
112
113
if (null === $ this ->center ) {
113
114
throw new InvalidArgumentException ('The map "center" must be explicitly set when not enabling "fitBoundsToMarkers" feature. ' );
114
115
}
115
-
116
+
116
117
if (null === $ this ->zoom ) {
117
118
throw new InvalidArgumentException ('The map "zoom" must be explicitly set when not enabling "fitBoundsToMarkers" feature. ' );
118
119
}
119
120
}
120
-
121
+
121
122
return [
122
123
'center ' => $ this ->center ?->toArray(),
123
124
'zoom ' => $ this ->zoom ,
@@ -148,23 +149,23 @@ public static function fromArray(array $map): self
148
149
if (isset ($ map ['center ' ])) {
149
150
$ map ['center ' ] = Point::fromArray ($ map ['center ' ]);
150
151
}
151
-
152
+
152
153
if (isset ($ map ['zoom ' ]) || isset ($ map ['center ' ])) {
153
154
$ map ['fitBoundsToMarkers ' ] = false ;
154
155
}
155
-
156
+
156
157
$ map ['markers ' ] ??= [];
157
158
if (!\is_array ($ map ['markers ' ])) {
158
159
throw new InvalidArgumentException ('The "markers" parameter must be an array. ' );
159
160
}
160
161
$ map ['markers ' ] = array_map (Marker::fromArray (...), $ map ['markers ' ]);
161
-
162
+
162
163
$ map ['polygons ' ] ??= [];
163
164
if (!\is_array ($ map ['polygons ' ])) {
164
165
throw new InvalidArgumentException ('The "polygons" parameter must be an array. ' );
165
166
}
166
167
$ map ['polygons ' ] = array_map (Polygon::fromArray (...), $ map ['polygons ' ]);
167
-
168
+
168
169
$ map ['polylines ' ] ??= [];
169
170
if (!\is_array ($ map ['polylines ' ])) {
170
171
throw new InvalidArgumentException ('The "polylines" parameter must be an array. ' );
0 commit comments