/** * Renders a size. * * @param \Ivory\GoogleMap\Base\Size $size The size. * * @return string The JS output. */ public function render(Size $size) { if ($size->hasUnits()) { return sprintf('%s = new google.maps.Size(%s, %s, "%s", "%s");' . PHP_EOL, $size->getJavascriptVariable(), $size->getWidth(), $size->getHeight(), $size->getWidthUnit(), $size->getHeightUnit()); } return sprintf('%s = new google.maps.Size(%s, %s);' . PHP_EOL, $size->getJavascriptVariable(), $size->getWidth(), $size->getHeight()); }
/** * Sets the pixel offset. * * Available prototypes: * - function setPixelOffset(Ivory\GoogleMap\Base\Size $scaledSize) * - function setPixelOffset(double $width, double $height, string $widthUnit = null, string $heightUnit = null) * * @throws \Ivory\GoogleMap\Exception\OverlayException If the pixel offset is not valid (prototypes). */ public function setPixelOffset() { $args = func_get_args(); if (isset($args[0]) && $args[0] instanceof Size) { $this->pixedOffset = $args[0]; } elseif (isset($args[0]) && is_numeric($args[0]) && (isset($args[1]) && is_numeric($args[1]))) { if ($this->pixedOffset === null) { $this->pixedOffset = new Size(); } $this->pixedOffset->setWidth($args[0]); $this->pixedOffset->setHeight($args[1]); if (isset($args[2]) && is_string($args[2])) { $this->pixedOffset->setWidthUnit($args[2]); } if (isset($args[3]) && is_string($args[3])) { $this->pixedOffset->setHeightUnit($args[3]); } } elseif (!isset($args[0])) { $this->pixedOffset = null; } else { throw OverlayException::invalidInfoWindowPixelOffset(); } }
/** * Sets the size of the marker image. * * Available prototypes: * - function setSize(Ivory\GoogleMap\Base\Size $size = null) * - function setSize(double $width, double $height, string $widthUnit = null, string $heightUnit = null) * * @throws \Ivory\GoogleMap\Exception\OverlayException If the size is not valid. */ public function setSize() { $args = func_get_args(); if (isset($args[0]) && $args[0] instanceof Size) { $this->size = $args[0]; } elseif (isset($args[0]) && is_numeric($args[0]) && (isset($args[1]) && is_numeric($args[1]))) { if ($this->size === null) { $this->size = new Size($args[0], $args[1]); } $this->size->setWidth($args[0]); $this->size->setHeight($args[1]); if (isset($args[2]) && is_string($args[2])) { $this->size->setWidthUnit($args[2]); } if (isset($args[3]) && is_string($args[3])) { $this->size->setHeightUnit($args[3]); } } elseif (!isset($args[0])) { $this->size = null; } else { throw OverlayException::invalidMarkerImageSize(); } }
public function testRenderWithUnits() { $size = new Size(1.1, 2.1, 'px', '%'); $size->setJavascriptVariable('foo'); $this->assertSame('foo = new google.maps.Size(1.1, 2.1, "px", "%");' . PHP_EOL, $this->sizeHelper->render($size)); }