/** * 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); }