Exemplo n.º 1
0
 /**
  * Sets the map type control.
  *
  * Available prototypes:
  *  - function setMapTypeControl(Ivory\GoogleMap\Controls\MapTypeControl $mapTypeControl = null)
  *  - function setMaptypeControl(array $mapTypeIds, string $controlPosition, string $mapTypeControlStyle)
  *
  * @throws \Ivory\GoogleMap\Exception\MapException If the map type control is not valid (prototypes).
  */
 public function setMapTypeControl()
 {
     $args = func_get_args();
     if (isset($args[0]) && $args[0] instanceof MapTypeControl) {
         $this->mapTypeControl = $args[0];
         $this->mapOptions['mapTypeControl'] = true;
     } elseif (isset($args[0]) && is_array($args[0]) && (isset($args[1]) && is_string($args[1])) && (isset($args[2]) && is_string($args[2]))) {
         if ($this->mapTypeControl === null) {
             $this->mapTypeControl = new MapTypeControl();
         }
         $this->mapTypeControl->setMapTypeIds($args[0]);
         $this->mapTypeControl->setControlPosition($args[1]);
         $this->mapTypeControl->setMapTypeControlStyle($args[2]);
         $this->mapOptions['mapTypeControl'] = true;
     } elseif (!isset($args[0])) {
         $this->mapTypeControl = null;
         if (isset($this->mapOptions['mapTypeControl'])) {
             unset($this->mapOptions['mapTypeControl']);
         }
     } else {
         throw MapException::invalidMapTypeControl();
     }
 }
 /**
  * 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();
 }
 /**
  * @expectedException \Ivory\GoogleMap\Exception\ControlException
  * @expectedExceptionMessage The map type control style can only be : default, dropdown_menu, horizontal_bar.
  */
 public function testMapTypeControlStyleWithInvalidValue()
 {
     $this->mapTypeControl->setMapTypeControlStyle('foo');
 }