| @@ 265-289 (lines=25) @@ | ||
| 262 | * |
|
| 263 | * @return self |
|
| 264 | */ |
|
| 265 | public function polygon(array $coordinates = [], array $options = []) |
|
| 266 | { |
|
| 267 | $items = $this->getItems(); |
|
| 268 | $parameters = $this->getOptions(); |
|
| 269 | ||
| 270 | $defaults = [ |
|
| 271 | 'coordinates' => $coordinates, |
|
| 272 | 'strokeColor' => '#FF0000', |
|
| 273 | 'strokeOpacity' => 0.8, |
|
| 274 | 'strokeWeight' => 2, |
|
| 275 | 'fillColor' => '#FF0000', |
|
| 276 | 'fillOpacity' => 0.35, |
|
| 277 | 'editable' => false |
|
| 278 | ]; |
|
| 279 | $options = array_replace_recursive(['user' => $parameters['user']], $defaults, $options); |
|
| 280 | ||
| 281 | if (empty($items)) { |
|
| 282 | throw new MapperException('No map found to add a polygon to.'); |
|
| 283 | } |
|
| 284 | ||
| 285 | $item = end($items); |
|
| 286 | $item->shape('polygon', $coordinates, $options); |
|
| 287 | ||
| 288 | return $this; |
|
| 289 | } |
|
| 290 | ||
| 291 | /** |
|
| 292 | * Add a new map rectangle. |
|
| @@ 301-325 (lines=25) @@ | ||
| 298 | * |
|
| 299 | * @return self |
|
| 300 | */ |
|
| 301 | public function rectangle(array $coordinates = [], array $options = []) |
|
| 302 | { |
|
| 303 | $items = $this->getItems(); |
|
| 304 | $parameters = $this->getOptions(); |
|
| 305 | ||
| 306 | $defaults = [ |
|
| 307 | 'coordinates' => $coordinates, |
|
| 308 | 'strokeColor' => '#FF0000', |
|
| 309 | 'strokeOpacity' => 0.8, |
|
| 310 | 'strokeWeight' => 2, |
|
| 311 | 'fillColor' => '#FF0000', |
|
| 312 | 'fillOpacity' => 0.35, |
|
| 313 | 'editable' => false |
|
| 314 | ]; |
|
| 315 | $options = array_replace_recursive(['user' => $parameters['user']], $defaults, $options); |
|
| 316 | ||
| 317 | if (empty($items)) { |
|
| 318 | throw new MapperException('No map found to add a rectangle to.'); |
|
| 319 | } |
|
| 320 | ||
| 321 | $item = end($items); |
|
| 322 | $item->shape('rectangle', $coordinates, $options); |
|
| 323 | ||
| 324 | return $this; |
|
| 325 | } |
|
| 326 | ||
| 327 | /** |
|
| 328 | * Add a new map circle. |
|
| @@ 337-362 (lines=26) @@ | ||
| 334 | * |
|
| 335 | * @return self |
|
| 336 | */ |
|
| 337 | public function circle(array $coordinates = [], array $options = []) |
|
| 338 | { |
|
| 339 | $items = $this->getItems(); |
|
| 340 | $parameters = $this->getOptions(); |
|
| 341 | ||
| 342 | $defaults = [ |
|
| 343 | 'coordinates' => $coordinates, |
|
| 344 | 'strokeColor' => '#FF0000', |
|
| 345 | 'strokeOpacity' => 0.8, |
|
| 346 | 'strokeWeight' => 2, |
|
| 347 | 'fillColor' => '#FF0000', |
|
| 348 | 'fillOpacity' => 0.35, |
|
| 349 | 'radius' => 100000, |
|
| 350 | 'editable' => false |
|
| 351 | ]; |
|
| 352 | $options = array_replace_recursive(['user' => $parameters['user']], $defaults, $options); |
|
| 353 | ||
| 354 | if (empty($items)) { |
|
| 355 | throw new MapperException('No map found to add a circle to.'); |
|
| 356 | } |
|
| 357 | ||
| 358 | $item = end($items); |
|
| 359 | $item->shape('circle', $coordinates, $options); |
|
| 360 | ||
| 361 | return $this; |
|
| 362 | } |
|
| 363 | ||
| 364 | } |
|
| 365 | ||