Markers may define an icon to show in place of the default icon. Defining an icon involves setting a number of properties that define the visual behavior of the marker.
First of all, if you want to render an icon, you will need to build one. So let's go:
use Ivory\GoogleMap\Overlay\Icon;
$icon = new Icon();
The icon constructor does not require anything but It accepts parameters such as the url (default https://maps.gstatic.com/mapfiles/markers/marker.png), anchor (default null), origin (default null), scaled size (default null) and size (default null):
use Ivory\GoogleMap\Base\Point;
use Ivory\GoogleMap\Base\Size;
use Ivory\GoogleMap\Overlay\Icon;
$icon = new Icon(
Icon::DEFAULT_URL,
new Point(20, 34),
new Point(0, 0),
new Size(20, 34),
new Size(40, 68)
);
A variable is automatically generated when creating an icon but if you want to update it, you can use:
$icon->setVariable('icon');
If you want to update thr url, you can use:
$icon->setUrl('https://maps.gstatic.com/mapfiles/markers/marker.png');
If you want to update the anchor, you can use:
use Ivory\GoogleMap\Base\Point;
$icon->setAnchor(new Point(20, 34));
If you want to update the origin, you can use:
use Ivory\GoogleMap\Base\Point;
$icon->setOrigin(new Point(0, 0));
If you want to update the size, you can use:
use Ivory\GoogleMap\Base\Size;
$icon->setSize(new Size(20, 34));
If you want to update the scaled size, you can use:
use Ivory\GoogleMap\Base\Size;
$icon->setScaledSize(new Size(20, 34));