public function testInitialState() { $mapTypeIds = array(MapTypeId::HYBRID); $controlPosition = ControlPosition::LEFT_TOP; $mapTypeControlStyle = MapTypeControlStyle::HORIZONTAL_BAR; $this->mapTypeControl = new MapTypeControl($mapTypeIds, $controlPosition, $mapTypeControlStyle); $this->assertSame($mapTypeIds, $this->mapTypeControl->getMapTypeIds()); $this->assertSame($controlPosition, $this->mapTypeControl->getControlPosition()); $this->assertSame($mapTypeControlStyle, $this->mapTypeControl->getMapTypeControlStyle()); }
/** * Renders a map type control. * * @param \Ivory\GoogleMap\Controls\MapTypeControl $mapTypeControl The map type control. * * @return string The JS output. */ public function render(MapTypeControl $mapTypeControl) { $this->jsonBuilder->reset(); foreach ($mapTypeControl->getMapTypeIds() as $index => $mapTypeId) { $this->jsonBuilder->setValue(sprintf('[mapTypeIds][%d]', $index), $this->mapTypeIdHelper->render($mapTypeId), false); } return $this->jsonBuilder->setValue('[position]', $this->controlPositionHelper->render($mapTypeControl->getControlPosition()), false)->setValue('[style]', $this->mapTypeControlStyleHelper->render($mapTypeControl->getMapTypeControlStyle()), false)->build(); }