public function testRenderWithOptions()
    {
        $map = $this->getMock('Ivory\\GoogleMap\\Map');
        $map->expects($this->once())->method('getJavascriptVariable')->will($this->returnValue('map'));
        $bound = new Bound();
        $bound->setJavascriptVariable('rectangleBound');
        $bound->setSouthWest(-1.1, -2.1);
        $bound->setNorthEast(1.1, 2.1);
        $rectangle = new Rectangle($bound);
        $rectangle->setJavascriptVariable('rectangle');
        $rectangle->setOptions(array('option1' => 'value1', 'option2' => 'value2'));
        $expected = <<<EOF
rectangle = new google.maps.Rectangle({"map":map,"bounds":rectangleBound,"option1":"value1","option2":"value2"});

EOF;
        $this->assertSame($expected, $this->rectangleHelper->render($rectangle, $map));
    }
Example #2
0
 /**
  * Renders the javascript container rectangles.
  *
  * @param \Ivory\GoogleMap\Map $map The map.
  *
  * @return string The JS output.
  */
 public function renderJsContainerRectangles(Map $map)
 {
     $output = array();
     foreach ($map->getRectangles() as $rectangle) {
         $output[] = sprintf('%s.rectangles.%s = %s', $this->getJsContainerName($map), $rectangle->getJavascriptVariable(), $this->rectangleHelper->render($rectangle, $map));
     }
     return implode('', $output);
 }