/** * Checks the render method */ public function testRender() { $boundTest = new Bound(); $this->assertEquals(self::$boundHelper->render($boundTest), 'var ' . $boundTest->getJavascriptVariable() . ' = new google.maps.LatLngBounds();' . PHP_EOL); $boundTest = new Bound(); $boundTest->setSouthWest(new Coordinate(-1.1, -2.1, false)); $boundTest->setNorthEast(new Coordinate(1.1, 2.1, true)); $this->assertEquals(self::$boundHelper->render($boundTest), 'var ' . $boundTest->getJavascriptVariable() . ' = new google.maps.LatLngBounds(new google.maps.LatLng(-1.1, -2.1, false), new google.maps.LatLng(1.1, 2.1, true));' . PHP_EOL); }
/** * 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); }