示例#1
0
 /**
  * Sets the map scale control.
  *
  * Available prototypes:
  *  - function setScaleControl(Ivory\GoogleMap\Controls\ScaleControl $scaleControl = null)
  *  - function setScaleControl(string $controlPosition, string $scaleControlStyle)
  *
  * @throws \Ivory\GoogleMap\Exception\MapException If the scale control is not valid (prototypes).
  */
 public function setScaleControl()
 {
     $args = func_get_args();
     if (isset($args[0]) && $args[0] instanceof ScaleControl) {
         $this->scaleControl = $args[0];
         $this->mapOptions['scaleControl'] = true;
     } elseif (isset($args[0]) && is_string($args[0]) && (isset($args[1]) && is_string($args[1]))) {
         if ($this->scaleControl === null) {
             $this->scaleControl = new ScaleControl();
         }
         $this->scaleControl->setControlPosition($args[0]);
         $this->scaleControl->setScaleControlStyle($args[1]);
         $this->mapOptions['scaleControl'] = true;
     } elseif (!isset($args[0])) {
         $this->scaleControl = null;
         if (isset($this->mapOptions['scaleControl'])) {
             unset($this->mapOptions['scaleControl']);
         }
     } else {
         throw MapException::invalidScaleControl();
     }
 }
 /**
  * Renders a scale control.
  *
  * @param \Ivory\GoogleMap\Controls\ScaleControl $scaleControl The scale control.
  *
  * @return string The JS output.
  */
 public function render(ScaleControl $scaleControl)
 {
     return $this->jsonBuilder->reset()->setValue('[position]', $this->controlPositionHelper->render($scaleControl->getControlPosition()), false)->setValue('[style]', $this->scaleControlStyleHelper->render($scaleControl->getScaleControlStyle()), false)->build();
 }
 /**
  * @expectedException \Ivory\GoogleMap\Exception\ControlException
  * @expectedExceptionMessage The scale control style of a scale control can only be : default.
  */
 public function testScaleControlStyleWithInvalidValue()
 {
     $this->scaleControl->setScaleControlStyle('foo');
 }