public function testRenderWithOptions()
 {
     $map = $this->getMock('Ivory\\GoogleMap\\Map');
     $map->expects($this->once())->method('getJavascriptVariable')->will($this->returnValue('map'));
     $polyline = new Polyline();
     $polyline->setJavascriptVariable('polyline');
     $polyline->addCoordinate(1.1, 2.1);
     $polyline->addCoordinate(3.1, 4.2);
     $polyline->addCoordinate(7.4, 12.6);
     foreach ($polyline->getCoordinates() as $index => $coordinate) {
         $coordinate->setJavascriptVariable('coordinate' . $index);
     }
     $polyline->setOptions(array('option1' => 'value1', 'option2' => 'value2'));
     $expected = 'polyline = new google.maps.Polyline({' . '"map":map,' . '"path":[' . 'coordinate0,' . 'coordinate1,' . 'coordinate2' . '],' . '"option1":"value1",' . '"option2":"value2"' . '});' . PHP_EOL;
     $this->assertSame($expected, $this->polylineHelper->render($polyline, $map));
 }
Beispiel #2
0
 /**
  * Renders the javascript container polylines.
  *
  * @param \Ivory\GoogleMap\Map $map The map.
  *
  * @return string The JS output.
  */
 public function renderJsContainerPolylines(Map $map)
 {
     $output = array();
     foreach ($map->getPolylines() as $polyline) {
         $output[] = sprintf('%s.polylines.%s = %s', $this->getJsContainerName($map), $polyline->getJavascriptVariable(), $this->polylineHelper->render($polyline, $map));
     }
     return implode('', $output);
 }