/**
  * 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 events
  *
  * @param Ivory\GoogleMapBundle\Model\Map $map
  * @return string HTML output
  */
 public function renderEvents(Map $map)
 {
     return $this->eventManagerHelper->render($map->getEventManager());
 }
 /**
  * Checks the render events method
  */
 public function testRenderEvents()
 {
     $mapTest = new Model\Map();
     $domEvent = new Events\Event();
     $domEvent->setInstance('instance');
     $domEvent->setEventName('event_name');
     $domEvent->setHandle('handle');
     $domEvent->setCapture(true);
     $mapTest->getEventManager()->addDomEvent($domEvent);
     $domEventOnce = new Events\Event();
     $domEventOnce->setInstance('instance');
     $domEventOnce->setEventName('event_name');
     $domEventOnce->setHandle('handle');
     $domEventOnce->setCapture(true);
     $mapTest->getEventManager()->addDomEventOnce($domEventOnce);
     $event = new Events\Event();
     $event->setInstance('instance');
     $event->setEventName('event_name');
     $event->setHandle('handle');
     $mapTest->getEventManager()->addEvent($event);
     $eventOnce = new Events\Event();
     $eventOnce->setInstance('instance');
     $eventOnce->setEventName('event_name');
     $eventOnce->setHandle('handle');
     $mapTest->getEventManager()->addEventOnce($eventOnce);
     $this->assertEquals(self::$mapHelper->renderEvents($mapTest), 'var ' . $domEvent->getJavascriptVariable() . ' = google.maps.event.addDomListener(instance, "event_name", handle, true);' . PHP_EOL . 'var ' . $domEventOnce->getJavascriptVariable() . ' = google.maps.event.addDomListenerOnce(instance, "event_name", handle, true);' . PHP_EOL . 'var ' . $event->getJavascriptVariable() . ' = google.maps.event.addListener(instance, "event_name", handle);' . PHP_EOL . 'var ' . $eventOnce->getJavascriptVariable() . ' = google.maps.event.addListenerOnce(instance, "event_name", handle);' . PHP_EOL);
 }
 /**
  * Create a map
  */
 public function __construct()
 {
     parent::__construct();
 }