/**
  * Renders the marker
  *
  * @param Ivory\GoogleMapBundle\Model\Overlays\Marker $marker
  * @param Ivory\GoogleMapBundle\Model\Map $map
  * @return string HTML output
  */
 public function render(Marker $marker, Map $map)
 {
     $html = array();
     $markerJSONOptions = sprintf('{"map":%s,"position":%s', $map->getJavascriptVariable(), $this->coordinateHelper->render($marker->getPosition()));
     $markerOptions = $marker->getOptions();
     if ($marker->hasAnimation()) {
         $markerJSONOptions .= ', "animation":' . $this->animationHelper->render($marker->getAnimation());
     }
     if ($marker->hasIcon()) {
         $html[] = $this->markerImageHelper->render($marker->getIcon());
         $markerJSONOptions .= ', "icon":' . $marker->getIcon()->getJavascriptVariable();
     }
     if ($marker->hasShadow()) {
         $html[] = $this->markerImageHelper->render($marker->getShadow());
         $markerJSONOptions .= ', "shadow":' . $marker->getShadow()->getJavascriptVariable();
     }
     if ($marker->hasShape()) {
         $html[] = $this->markerShapeHelper->render($marker->getShape());
         $markerJSONOptions .= ', "shape":' . $marker->getShape()->getJavascriptVariable();
     }
     if (!empty($markerOptions)) {
         $markerJSONOptions .= ',' . substr(json_encode($markerOptions), 1);
     } else {
         $markerJSONOptions .= '}';
     }
     $html[] = sprintf('var %s = new google.maps.Marker(%s);' . PHP_EOL, $marker->getJavascriptVariable(), $markerJSONOptions);
     if ($marker->hasInfoWindow()) {
         $html[] = $this->infoWindowHelper->render($marker->getInfoWindow(), false);
         if ($marker->getInfoWindow()->isOpen()) {
             $html[] = $this->infoWindowHelper->renderOpen($marker->getInfoWindow(), $map, $marker);
         }
     }
     return implode('', $html);
 }
 /**
  * Renders the map javascript circle
  *
  * @param Ivory\GoogleMapBundle\Model\Overlays\Circle $circle
  * @param Ivory\GoogleMapBundle\Model\Map $map
  */
 public function render(Circle $circle, Map $map)
 {
     $circleOptions = array_merge(array('radius' => $circle->getRadius()), $circle->getOptions());
     $circleJSONOptions = sprintf('{"map":%s,"center":%s,', $map->getJavascriptVariable(), $this->coordinateHelper->render($circle->getCenter()));
     $circleJSONOptions .= substr(json_encode($circleOptions), 1);
     return sprintf('var %s = new google.maps.Circle(%s);' . PHP_EOL, $circle->getJavascriptVariable(), $circleJSONOptions);
 }
 /**
  * Renders the encoded polyline
  *
  * @param Ivory\GoogleMapBundle\Model\Overlays\EncodedPolyline $encodedPolyline
  * @param Ivory\GoogleMapBundle\Model\Map $map
  * @return string HTML output
  */
 public function render(EncodedPolyline $encodedPolyline, Map $map)
 {
     $polylineOptions = $encodedPolyline->getOptions();
     $polylineJSONOptions = sprintf('{"map":%s,"path":%s', $map->getJavascriptVariable(), $this->encodingHelper->renderDecodePath($encodedPolyline->getValue()));
     if (!empty($polylineOptions)) {
         $polylineJSONOptions .= ',' . substr(json_encode($polylineOptions), 1);
     } else {
         $polylineJSONOptions .= '}';
     }
     return sprintf('var %s = new google.maps.Polyline(%s);' . PHP_EOL, $encodedPolyline->getJavascriptVariable(), $polylineJSONOptions);
 }
 /**
  * Renders the map javascript kml layer
  *
  * @param Ivory\GoogleMapBundle\Model\Layers\KMLLayer $kmlLayer The KML layer
  * @param Ivory\GoogleMapBundle\Model\Map $map The map
  */
 public function render(KMLLayer $kmlLayer, Map $map)
 {
     $kmlLayerOptions = $kmlLayer->getOptions();
     $kmlLayerJSONOptions = sprintf('{"map":%s', $map->getJavascriptVariable());
     if (!empty($kmlLayerOptions)) {
         $kmlLayerJSONOptions .= ',' . substr(json_encode($kmlLayerOptions), 1);
     } else {
         $kmlLayerJSONOptions .= '}';
     }
     return sprintf('var %s = new google.maps.KmlLayer("%s", %s);' . PHP_EOL, $kmlLayer->getJavascriptVariable(), $kmlLayer->getUrl(), $kmlLayerJSONOptions);
 }
 /**
  * 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);
 }
 /**
  * Renders the polygon
  *
  * @param Ivory\GoogleMapBundle\Model\Overlays\Polygon $polygon
  * @param Ivory\GoogleMapBundle\Model\Map $map
  * @return string HTML output
  */
 public function render(Polygon $polygon, Map $map)
 {
     $polygonOptions = $polygon->getOptions();
     $polygonCoordinates = array();
     foreach ($polygon->getCoordinates() as $coordinate) {
         $polygonCoordinates[] = $this->coordinateHelper->render($coordinate);
     }
     $polygonJSONOptions = sprintf('{"map":%s,"paths":%s', $map->getJavascriptVariable(), '[' . implode(',', $polygonCoordinates) . ']');
     if (!empty($polygonOptions)) {
         $polygonJSONOptions .= ',' . substr(json_encode($polygonOptions), 1);
     } else {
         $polygonJSONOptions .= '}';
     }
     return sprintf('var %s = new google.maps.Polygon(%s);' . PHP_EOL, $polygon->getJavascriptVariable(), $polygonJSONOptions);
 }
 /**
  * Renders the map javascript bound
  *
  * @param Ivory\GoogleMapBundle\Model\Map $map
  * @return string HTML output
  */
 public function renderBound(Map $map)
 {
     $html = array();
     $html[] = $this->boundHelper->render($map->getBound());
     $html[] = sprintf('%s.fitBounds(%s);' . PHP_EOL, $map->getJavascriptVariable(), $map->getBound()->getJavascriptVariable());
     return implode('', $html);
 }