public function testRenderWithOptions() { $map = $this->getMock('Ivory\\GoogleMap\\Map'); $map->expects($this->once())->method('getJavascriptVariable')->will($this->returnValue('map')); $kmlLayer = new KMLLayer('url'); $kmlLayer->setJavascriptVariable('kmlLayer'); $kmlLayer->setOptions(array('option1' => 'value1', 'option2' => 'value2')); $expected = 'kmlLayer = new google.maps.KmlLayer(' . '"url", ' . '{"map":map,"option1":"value1","option2":"value2"}' . ');' . PHP_EOL; $this->assertSame($expected, $this->kmlLayerHelper->render($kmlLayer, $map)); }
/** * Renders the javascript container KML layer. * * @param \Ivory\GoogleMap\Map $map The map. * * @return string The JS output. */ public function renderJsContainerKMLLayers(Map $map) { $output = array(); foreach ($map->getKMLLayers() as $kmlLayer) { $output[] = sprintf('%s.kml_layers.%s = %s', $this->getJsContainerName($map), $kmlLayer->getJavascriptVariable(), $this->kmlLayerHelper->render($kmlLayer, $map)); } return implode('', $output); }