The map type control lets the user toggle between map types (such as ROADMAP and SATELLITE). This control appears by default in the top right corner of the map.
First of all, if you want to render a map type control, you will need to build one. So let's go:
use Ivory\GoogleMap\Control\MapTypeControl;
$mapTypeControl = new MapTypeControl();
The map type control constructor does not require anything but it accepts parameters such as ids (default roadmap, satellite), position (default top right) and style (default default):
use Ivory\GoogleMap\Control\ControlPosition;
use Ivory\GoogleMap\Control\MapTypeControl;
use Ivory\GoogleMap\Control\MapTypeControlStyle;
use Ivory\GoogleMap\MapTypeId;
$mapTypeControl = new MapTypeControl(
[MapTypeId::ROADMAP, MapTypeId::SATELLITE],
ControlPosition::TOP_RIGHT,
MapTypeControlStyle::DEFAULT_
);
If you want to update ids, you can use:
use Ivory\GoogleMap\MapTypeId;
$mapTypeControl->setIds([MapTypeId::ROADMAP, MapTypeId::SATELLITE]);
If you want to update position, you can use:
use Ivory\GoogleMap\Control\ControlPosition;
$mapTypeControl->setPosition(ControlPosition::TOP_RIGHT);
If you want to update the style, you can use:
use Ivory\GoogleMap\Control\MapTypeControlStyle;
$mapTypeControl->setStyle(MapTypeControlStyle::DEFAULT_);
After building your map type control, you need to add it to a map with:
$map->getControlManager()->setMapTypeControl($mapTypeControl);