/**
  * Renders the rectangle
  *
  * @param Ivory\GoogleMapBundle\Model\Overlays\Rectangle $rectangle
  * @param Ivory\GoogleMapBundle\Model\Map $map
  * @return string HTML output
  */
 public function render(Rectangle $rectangle, Map $map)
 {
     $rectangleOptions = $rectangle->getOptions();
     $rectangleJSONOptions = sprintf('{"map":%s,"bounds":%s', $map->getJavascriptVariable(), $rectangle->getBound()->getJavascriptVariable());
     if (!empty($rectangleOptions)) {
         $rectangleJSONOptions .= ',' . substr(json_encode($rectangleOptions), 1);
     } else {
         $rectangleJSONOptions .= '}';
     }
     $html = array();
     $html[] = $this->boundHelper->render($rectangle->getBound());
     $html[] = sprintf('var %s = new google.maps.Rectangle(%s);' . PHP_EOL, $rectangle->getJavascriptVariable(), $rectangleJSONOptions);
     return implode('', $html);
 }
 /**
  * Renders the map javascript ground overlay
  *
  * @param Ivory\GoogleMapBundle\Model\Overlays\GroundOverlay $groundOverlay
  * @param Ivory\GoogleMapBundle\Model\Map $map
  * @return string HTML output
  */
 public function render(GroundOverlay $groundOverlay, Map $map)
 {
     $groundOverlayOptions = $groundOverlay->getOptions();
     $groundOverlayJSONOptions = sprintf('{"map":%s', $map->getJavascriptVariable());
     if (!empty($groundOverlayOptions)) {
         $groundOverlayJSONOptions .= ',' . substr(json_encode($groundOverlayOptions), 1);
     } else {
         $groundOverlayJSONOptions .= '}';
     }
     $html = array();
     $html[] = $this->boundHelper->render($groundOverlay->getBound());
     $html[] = sprintf('var %s = new google.maps.GroundOverlay("%s", %s, %s);' . PHP_EOL, $groundOverlay->getJavascriptVariable(), $groundOverlay->getUrl(), $groundOverlay->getBound()->getJavascriptVariable(), $groundOverlayJSONOptions);
     return implode('', $html);
 }
 /**
  * Checks the render extends methos
  */
 public function testRenderExtends()
 {
     $boundTest = new Bound();
     $circleTest = new Overlays\Circle();
     $boundTest->extend($circleTest);
     $groundOverlayTest = new Overlays\GroundOverlay();
     $boundTest->extend($groundOverlayTest);
     $infoWindowTest = new Overlays\InfoWindow();
     $boundTest->extend($infoWindowTest);
     $markerTest = new Overlays\Marker();
     $boundTest->extend($markerTest);
     $polygonTest = new Overlays\Polygon();
     $boundTest->extend($polygonTest);
     $polylineTest = new Overlays\Polyline();
     $boundTest->extend($polylineTest);
     $rectangleTest = new Overlays\Rectangle();
     $boundTest->extend($rectangleTest);
     $this->assertEquals(self::$boundHelper->renderExtends($boundTest), $boundTest->getJavascriptVariable() . '.union(' . $circleTest->getJavascriptVariable() . '.getBounds());' . PHP_EOL . $boundTest->getJavascriptVariable() . '.union(' . $groundOverlayTest->getBound()->getJavascriptVariable() . ');' . PHP_EOL . $boundTest->getJavascriptVariable() . '.extend(' . $infoWindowTest->getJavascriptVariable() . '.getPosition());' . PHP_EOL . $boundTest->getJavascriptVariable() . '.extend(' . $markerTest->getJavascriptVariable() . '.getPosition());' . PHP_EOL . $polygonTest->getJavascriptVariable() . '.getPath().forEach(function(element){' . $boundTest->getJavascriptVariable() . '.extend(element)});' . PHP_EOL . $polylineTest->getJavascriptVariable() . '.getPath().forEach(function(element){' . $boundTest->getJavascriptVariable() . '.extend(element)});' . PHP_EOL . $boundTest->getJavascriptVariable() . '.union(' . $rectangleTest->getBound()->getJavascriptVariable() . ');' . PHP_EOL);
 }