Exemplo n.º 1
0
 /**
  * Sets the map zoom control.
  *
  * Available prototypes:
  *  - function setZoomControl(Ivory\GoogleMap\Controls\ZoomControl $zoomControl = null)
  *  - function setZoomControl(string $controlPosition, string $zoomControlStyle)
  *
  * @throws \Ivory\GoogleMap\Exception\MapException If the zoom control is not valid (prototypes).
  */
 public function setZoomControl()
 {
     $args = func_get_args();
     if (isset($args[0]) && $args[0] instanceof ZoomControl) {
         $this->zoomControl = $args[0];
         $this->mapOptions['zoomControl'] = true;
     } elseif (isset($args[0]) && is_string($args[0]) && (isset($args[1]) && is_string($args[1]))) {
         if ($this->zoomControl === null) {
             $this->zoomControl = new ZoomControl();
         }
         $this->zoomControl->setControlPosition($args[0]);
         $this->zoomControl->setZoomControlStyle($args[1]);
         $this->mapOptions['zoomControl'] = true;
     } elseif (!isset($args[0])) {
         $this->zoomControl = null;
         if (isset($this->mapOptions['zoomControl'])) {
             unset($this->mapOptions['zoomControl']);
         }
     } else {
         throw MapException::invalidZoomControl();
     }
 }
 /**
  * Renders a zoom control.
  *
  * @param \Ivory\GoogleMap\Controls\ZoomControl $zoomControl The zoom control.
  *
  * @return string The JS output.
  */
 public function render(ZoomControl $zoomControl)
 {
     return $this->jsonBuilder->reset()->setValue('[position]', $this->controlPositionHelper->render($zoomControl->getControlPosition()), false)->setValue('[style]', $this->zoomControlStyleHelper->render($zoomControl->getZoomControlStyle()), false)->build();
 }
 /**
  * @expectedException \Ivory\GoogleMap\Exception\ControlException
  * @expectedExceptionMessage The zoom control style of a zoom control can only be : default, large, small.
  */
 public function testZoomControlStyleWithInvalidValue()
 {
     $this->zoomControl->setZoomControlStyle('foo');
 }