| @@ 300-324 (lines=25) @@ | ||
| 297 | * |
|
| 298 | * @return self |
|
| 299 | */ |
|
| 300 | public function polygon(array $coordinates = [], array $options = []) |
|
| 301 | { |
|
| 302 | $items = $this->getItems(); |
|
| 303 | $parameters = $this->getOptions(); |
|
| 304 | ||
| 305 | $defaults = [ |
|
| 306 | 'coordinates' => $coordinates, |
|
| 307 | 'strokeColor' => '#FF0000', |
|
| 308 | 'strokeOpacity' => 0.8, |
|
| 309 | 'strokeWeight' => 2, |
|
| 310 | 'fillColor' => '#FF0000', |
|
| 311 | 'fillOpacity' => 0.35, |
|
| 312 | 'editable' => false |
|
| 313 | ]; |
|
| 314 | $options = array_replace_recursive(['user' => $parameters['user']], $defaults, $options); |
|
| 315 | ||
| 316 | if (empty($items)) { |
|
| 317 | throw new MapperException('No map found to add a polygon to.'); |
|
| 318 | } |
|
| 319 | ||
| 320 | $item = end($items); |
|
| 321 | $item->shape('polygon', $coordinates, $options); |
|
| 322 | ||
| 323 | return $this; |
|
| 324 | } |
|
| 325 | ||
| 326 | /** |
|
| 327 | * Add a new map rectangle. |
|
| @@ 336-360 (lines=25) @@ | ||
| 333 | * |
|
| 334 | * @return self |
|
| 335 | */ |
|
| 336 | public function rectangle(array $coordinates = [], array $options = []) |
|
| 337 | { |
|
| 338 | $items = $this->getItems(); |
|
| 339 | $parameters = $this->getOptions(); |
|
| 340 | ||
| 341 | $defaults = [ |
|
| 342 | 'coordinates' => $coordinates, |
|
| 343 | 'strokeColor' => '#FF0000', |
|
| 344 | 'strokeOpacity' => 0.8, |
|
| 345 | 'strokeWeight' => 2, |
|
| 346 | 'fillColor' => '#FF0000', |
|
| 347 | 'fillOpacity' => 0.35, |
|
| 348 | 'editable' => false |
|
| 349 | ]; |
|
| 350 | $options = array_replace_recursive(['user' => $parameters['user']], $defaults, $options); |
|
| 351 | ||
| 352 | if (empty($items)) { |
|
| 353 | throw new MapperException('No map found to add a rectangle to.'); |
|
| 354 | } |
|
| 355 | ||
| 356 | $item = end($items); |
|
| 357 | $item->shape('rectangle', $coordinates, $options); |
|
| 358 | ||
| 359 | return $this; |
|
| 360 | } |
|
| 361 | ||
| 362 | /** |
|
| 363 | * Add a new map circle. |
|
| @@ 372-397 (lines=26) @@ | ||
| 369 | * |
|
| 370 | * @return self |
|
| 371 | */ |
|
| 372 | public function circle(array $coordinates = [], array $options = []) |
|
| 373 | { |
|
| 374 | $items = $this->getItems(); |
|
| 375 | $parameters = $this->getOptions(); |
|
| 376 | ||
| 377 | $defaults = [ |
|
| 378 | 'coordinates' => $coordinates, |
|
| 379 | 'strokeColor' => '#FF0000', |
|
| 380 | 'strokeOpacity' => 0.8, |
|
| 381 | 'strokeWeight' => 2, |
|
| 382 | 'fillColor' => '#FF0000', |
|
| 383 | 'fillOpacity' => 0.35, |
|
| 384 | 'radius' => 100000, |
|
| 385 | 'editable' => false |
|
| 386 | ]; |
|
| 387 | $options = array_replace_recursive(['user' => $parameters['user']], $defaults, $options); |
|
| 388 | ||
| 389 | if (empty($items)) { |
|
| 390 | throw new MapperException('No map found to add a circle to.'); |
|
| 391 | } |
|
| 392 | ||
| 393 | $item = end($items); |
|
| 394 | $item->shape('circle', $coordinates, $options); |
|
| 395 | ||
| 396 | return $this; |
|
| 397 | } |
|
| 398 | ||
| 399 | } |
|
| 400 | ||