/** * 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); }
/** * Checks the render method */ public function testRender() { $mapTest = new Map(); $circleTest = new Circle(); $circleTest->setCenter(new Coordinate(1.1, 2.1, true)); $circleTest->setRadius(2); $circleTest->setOptions(array('option1' => 'value1', 'option2' => 'value2')); $this->assertEquals(self::$circleHelper->render($circleTest, $mapTest), 'var ' . $circleTest->getJavascriptVariable() . ' = new google.maps.Circle({"map":' . $mapTest->getJavascriptVariable() . ',"center":new google.maps.LatLng(1.1, 2.1, true),"radius":2,"option1":"value1","option2":"value2"});' . PHP_EOL); }
/** * Checks the render circles method */ public function testRenderCircles() { $mapTest = new Model\Map(); $circleTest = new Overlays\Circle(); $circleTest->setCenter(new Base\Coordinate(1.1, 2.1, true)); $circleTest->setRadius(2); $mapTest->addCircle($circleTest); $this->assertEquals(self::$mapHelper->renderCircles($mapTest), 'var ' . $circleTest->getJavascriptVariable() . ' = new google.maps.Circle({"map":' . $mapTest->getJavascriptVariable() . ',"center":new google.maps.LatLng(1.1, 2.1, true),"radius":2});' . PHP_EOL); }
/** * Create a circle */ public function __construct() { parent::__construct(); }