public function testRenderWithPosition() { $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 google.maps.InfoWindow({' . '"pixelOffset":pixel_offset,' . '"content":"content",' . '"option1":"value1",' . '"option2":"value2"' . '});' . PHP_EOL; $this->assertSame($expected, $this->infoWindowHelper->render($infoWindow, false)); }
/** * Renders the javascript container info windows. * * @param \Ivory\GoogleMap\Map $map The map. * * @return string The JS output. */ public function renderJsContainerInfoWindows(Map $map) { $output = array(); $mapInfoWindows = $map->getInfoWindows(); $markerInfoWindows = $this->computeMarkerInfoWindows($map); foreach ($mapInfoWindows as $mapInfoWindow) { $output[] = sprintf('%s.info_windows.%s = %s', $this->getJsContainerName($map), $mapInfoWindow->getJavascriptVariable(), $this->infoWindowHelper->render($mapInfoWindow)); } foreach ($markerInfoWindows as $markerInfoWindow) { $output[] = sprintf('%s.info_windows.%s = %s', $this->getJsContainerName($map), $markerInfoWindow->getJavascriptVariable(), $this->infoWindowHelper->render($markerInfoWindow, false)); } foreach (array_merge($mapInfoWindows, $markerInfoWindows) as $infoWindow) { if ($infoWindow->isAutoClose()) { $output[] = sprintf('%s.closable_info_windows.%s = %s;' . PHP_EOL, $this->getJsContainerName($map), $infoWindow->getJavascriptVariable(), $infoWindow->getJavascriptVariable()); } } return implode('', $output); }