/** * Sets the map rotate control. * * Available prototypes: * - function setRotateControl(Ivory\GoogleMap\Controls\RotateControl $rotateControl = null) * - function setRotateControl(string $controlPosition) * * @throws \Ivory\GoogleMap\Exception\MapException If the rotate control is not valid (prototypes). */ public function setRotateControl() { $args = func_get_args(); if (isset($args[0]) && $args[0] instanceof RotateControl) { $this->rotateControl = $args[0]; $this->mapOptions['rotateControl'] = true; } elseif (isset($args[0]) && is_string($args[0])) { if ($this->rotateControl === null) { $this->rotateControl = new RotateControl(); } $this->rotateControl->setControlPosition($args[0]); $this->mapOptions['rotateControl'] = true; } elseif (!isset($args[0])) { $this->rotateControl = null; if (isset($this->mapOptions['rotateControl'])) { unset($this->mapOptions['rotateControl']); } } else { throw MapException::invalidRotateControl(); } }
/** * Renders a rotate control. * * @param \Ivory\GoogleMap\Controls\RotateControl $rotateControl The rotate control. * * @return string The JS output. */ public function render(RotateControl $rotateControl) { return $this->jsonBuilder->reset()->setValue('[position]', $this->controlPositionHelper->render($rotateControl->getControlPosition()), false)->build(); }
/** * @expectedException \Ivory\GoogleMap\Exception\ControlException */ public function testControlPositionWithInvalidValue() { $this->rotateControl->setControlPosition('foo'); }