A Rectangle is similar to a Polygon in that you can define custom colors, weights, and opacities for the edge of the rectangle (the "stroke") and custom colors and opacities for the area within the enclosed region (the "fill"). Unlike a Polygon, you do not define paths for a Rectangle; instead, a rectangle has one additional property which defines its shape : the bound.
First of all, if you want to render a circle, you will need to build one. So let's go:
use Ivory\GoogleMap\Base\Base;
use Ivory\GoogleMap\Base\Coordinate;
use Ivory\GoogleMap\Overlay\Rectangle;
$rectangle = new Rectangle(new Bound(
new Coordinate(-1, -1),
new Coordinate(1, 1)
));
The rectangle constructor requires a bound as first argument which represents its area. It also accepts additional parameters such as options (default empty):
use Ivory\GoogleMap\Base\Base;
use Ivory\GoogleMap\Base\Coordinate;
use Ivory\GoogleMap\Overlay\Rectangle;
$rectangle = new Rectangle(
new Bound(
new Coordinate(-1, -1),
new Coordinate(1, 1)
),
['clickable' => false]
);
A variable is automatically generated when creating a rectangle but if you want to update it, you can use:
$rectangle->setVriable('rectangle');
If you want to update the bound, you can use:
use Ivory\GoogleMap\Base\Base;
use Ivory\GoogleMap\Base\Coordinate;
$rectangle->setBound(new Bound(
new Coordinate(-1, -1),
new Coordinate(1, 1)
));
The rectangle options allows you to configure additional rectangle aspects. See the list of available options in the official documentation. Then, to configure them, you can use:
$rectangle->setOption('clickable', false);
After building your rectangle, you need to add it to a map with:
$map->getOverlayManager()->addRectangle($rectangle);