| @@ 330-354 (lines=25) @@ | ||
| 327 | * |
|
| 328 | * @return self |
|
| 329 | */ |
|
| 330 | public function polygon(array $coordinates = [], array $options = []) |
|
| 331 | { |
|
| 332 | $items = $this->getItems(); |
|
| 333 | $parameters = $this->getOptions(); |
|
| 334 | ||
| 335 | $defaults = [ |
|
| 336 | 'coordinates' => $coordinates, |
|
| 337 | 'strokeColor' => '#FF0000', |
|
| 338 | 'strokeOpacity' => 0.8, |
|
| 339 | 'strokeWeight' => 2, |
|
| 340 | 'fillColor' => '#FF0000', |
|
| 341 | 'fillOpacity' => 0.35, |
|
| 342 | 'editable' => false |
|
| 343 | ]; |
|
| 344 | $options = array_replace_recursive(['user' => $parameters['user']], $defaults, $options); |
|
| 345 | ||
| 346 | if (empty($items)) { |
|
| 347 | throw new MapperException('No map found to add a polygon to.'); |
|
| 348 | } |
|
| 349 | ||
| 350 | $item = end($items); |
|
| 351 | $item->shape('polygon', $coordinates, $options); |
|
| 352 | ||
| 353 | return $this; |
|
| 354 | } |
|
| 355 | ||
| 356 | /** |
|
| 357 | * Add a new map rectangle. |
|
| @@ 366-390 (lines=25) @@ | ||
| 363 | * |
|
| 364 | * @return self |
|
| 365 | */ |
|
| 366 | public function rectangle(array $coordinates = [], array $options = []) |
|
| 367 | { |
|
| 368 | $items = $this->getItems(); |
|
| 369 | $parameters = $this->getOptions(); |
|
| 370 | ||
| 371 | $defaults = [ |
|
| 372 | 'coordinates' => $coordinates, |
|
| 373 | 'strokeColor' => '#FF0000', |
|
| 374 | 'strokeOpacity' => 0.8, |
|
| 375 | 'strokeWeight' => 2, |
|
| 376 | 'fillColor' => '#FF0000', |
|
| 377 | 'fillOpacity' => 0.35, |
|
| 378 | 'editable' => false |
|
| 379 | ]; |
|
| 380 | $options = array_replace_recursive(['user' => $parameters['user']], $defaults, $options); |
|
| 381 | ||
| 382 | if (empty($items)) { |
|
| 383 | throw new MapperException('No map found to add a rectangle to.'); |
|
| 384 | } |
|
| 385 | ||
| 386 | $item = end($items); |
|
| 387 | $item->shape('rectangle', $coordinates, $options); |
|
| 388 | ||
| 389 | return $this; |
|
| 390 | } |
|
| 391 | ||
| 392 | /** |
|
| 393 | * Add a new map circle. |
|
| @@ 402-427 (lines=26) @@ | ||
| 399 | * |
|
| 400 | * @return self |
|
| 401 | */ |
|
| 402 | public function circle(array $coordinates = [], array $options = []) |
|
| 403 | { |
|
| 404 | $items = $this->getItems(); |
|
| 405 | $parameters = $this->getOptions(); |
|
| 406 | ||
| 407 | $defaults = [ |
|
| 408 | 'coordinates' => $coordinates, |
|
| 409 | 'strokeColor' => '#FF0000', |
|
| 410 | 'strokeOpacity' => 0.8, |
|
| 411 | 'strokeWeight' => 2, |
|
| 412 | 'fillColor' => '#FF0000', |
|
| 413 | 'fillOpacity' => 0.35, |
|
| 414 | 'radius' => 100000, |
|
| 415 | 'editable' => false |
|
| 416 | ]; |
|
| 417 | $options = array_replace_recursive(['user' => $parameters['user']], $defaults, $options); |
|
| 418 | ||
| 419 | if (empty($items)) { |
|
| 420 | throw new MapperException('No map found to add a circle to.'); |
|
| 421 | } |
|
| 422 | ||
| 423 | $item = end($items); |
|
| 424 | $item->shape('circle', $coordinates, $options); |
|
| 425 | ||
| 426 | return $this; |
|
| 427 | } |
|
| 428 | ||
| 429 | } |
|
| 430 | ||