/** * Renders the info window open flag. * * @param \Ivory\GoogleMap\Overlays\InfoWindow $infoWindow The info window. * @param \Ivory\GoogleMap\Map $map The map. * @param \Ivory\GoogleMap\Overlays\Marker $marker The marker. * * @return string The JS output. */ public function renderOpen(InfoWindow $infoWindow, Map $map, Marker $marker = null) { if ($marker !== null) { return sprintf('%s.open(%s, %s);' . PHP_EOL, $infoWindow->getJavascriptVariable(), $map->getJavascriptVariable(), $marker->getJavascriptVariable()); } return sprintf('%s.open(%s);' . PHP_EOL, $infoWindow->getJavascriptVariable(), $map->getJavascriptVariable()); }
public function testRender() { $infoWindow = new InfoWindow(); $infoWindow->setPosition(1.1, 2.1, true); $infoWindow->getPosition()->setJavascriptVariable('position'); $infoWindow->setPixelOffset(3, 4, 'px', 'px'); $infoWindow->getPixelOffset()->setJavascriptVariable('pixel_offset'); $infoWindow->setContent('content'); $infoWindow->setOpen(true); $infoWindow->setOptions(array('option1' => 'value1', 'option2' => 'value2')); $expected = $infoWindow->getJavascriptVariable() . ' = new InfoBox({' . '"position":position,' . '"pixelOffset":pixel_offset,' . '"content":"content",' . '"option1":"value1",' . '"option2":"value2"' . '});' . PHP_EOL; $this->assertSame($expected, $this->infoBoxHelper->render($infoWindow, true)); }