/** * @param $markerBuilder * @param $stationState * @param $infoWindowBuilder * * @return Marker */ private function getMarker(MarkerBuilder $markerBuilder, StationState $stationState, InfoWindowBuilder $infoWindowBuilder) { $marker = $markerBuilder->build(); $station = $stationState->getStation(); $marker->setPosition($station->getLatitude(), $station->getLongitude()); $infoWindow = $infoWindowBuilder->build(); $path = $this->get('router')->generate('station_state_graph', array('stationId' => $station->getId())); $infoWindow->setContent(sprintf('Bikes remaining : %d <br />Free spaces: %d <br /> Link: <a href="%s">Graph</a> ', $stationState->getAvailableBikes(), $stationState->getFreeSlots(), $path)); $marker->setInfoWindow($infoWindow); return $marker; }
public function testMultipleBuildWithReset() { $this->infoWindowBuilder->setPrefixJavascriptVariable('foo')->setContent('bar')->setPosition(1, 2, false)->setPixelOffset(3, 4, 'px', 'pt')->setOpen(true)->setOpenEvent(MouseEvent::DBLCLICK)->setAutoOpen(false)->setAutoClose(true)->setOptions(array('foo' => 'bar')); $infoWindow1 = $this->infoWindowBuilder->build(); $this->infoWindowBuilder->reset(); $infoWindow2 = $this->infoWindowBuilder->build(); $this->assertSame('foo', substr($infoWindow1->getJavascriptVariable(), 0, 3)); $this->assertSame('bar', $infoWindow1->getContent()); $this->assertSame(1, $infoWindow1->getPosition()->getLatitude()); $this->assertSame(2, $infoWindow1->getPosition()->getLongitude()); $this->assertFalse($infoWindow1->getPosition()->isNoWrap()); $this->assertSame(3, $infoWindow1->getPixelOffset()->getWidth()); $this->assertSame(4, $infoWindow1->getPixelOffset()->getHeight()); $this->assertSame('px', $infoWindow1->getPixelOffset()->getWidthUnit()); $this->assertSame('pt', $infoWindow1->getPixelOffset()->getHeightUnit()); $this->assertTrue($infoWindow1->isOpen()); $this->assertSame(MouseEvent::DBLCLICK, $infoWindow1->getOpenEvent()); $this->assertFalse($infoWindow1->isAutoOpen()); $this->assertTrue($infoWindow1->isAutoClose()); $this->assertSame(array('foo' => 'bar'), $infoWindow1->getOptions()); $this->assertSame('info_window_', substr($infoWindow2->getJavascriptVariable(), 0, 12)); $this->assertSame('<p>Default content</p>', $infoWindow2->getContent()); $this->assertNull($infoWindow2->getPosition()); $this->assertNull($infoWindow2->getPixelOffset()); $this->assertFalse($infoWindow2->isOpen()); $this->assertSame(MouseEvent::CLICK, $infoWindow2->getOpenEvent()); $this->assertTrue($infoWindow2->isAutoOpen()); $this->assertFalse($infoWindow2->isAutoClose()); $this->assertEmpty($infoWindow2->getOptions()); }