/** * Checks the render method */ public function testRender() { $sizeTest = new Size(1.1, 2.1); $this->assertEquals(self::$sizeHelper->render($sizeTest), 'new google.maps.Size(1.1, 2.1)'); $sizeTest = new Size(1.1, 2.1, 'px', 'px'); $this->assertEquals(self::$sizeHelper->render($sizeTest), 'new google.maps.Size(1.1, 2.1, "px", "px")'); }
/** * Renders the marker image * * @param Ivory\GoogleMapBundle\Model\Overlays\MarkerImage $markerImage * @return string HTML output */ public function render(MarkerImage $markerImage) { $html = array(); $html[] = sprintf('var %s = new google.maps.MarkerImage("%s");' . PHP_EOL, $markerImage->getJavascriptVariable(), $markerImage->getUrl()); if ($markerImage->hasSize()) { $html[] = sprintf('%s.size = %s;' . PHP_EOL, $markerImage->getJavascriptVariable(), $this->sizeHelper->render($markerImage->getSize())); } if ($markerImage->hasOrigin()) { $html[] = sprintf('%s.origin = %s;' . PHP_EOL, $markerImage->getJavascriptVariable(), $this->pointHelper->render($markerImage->getOrigin())); } if ($markerImage->hasAnchor()) { $html[] = sprintf('%s.anchor = %s;' . PHP_EOL, $markerImage->getJavascriptVariable(), $this->pointHelper->render($markerImage->getAnchor())); } if ($markerImage->hasScaledSize()) { $html[] = sprintf('%s.scaledSize = %s;' . PHP_EOL, $markerImage->getJavascriptVariable(), $this->sizeHelper->render($markerImage->getScaledSize())); } return implode('', $html); }