/** * Checks the render method */ public function testRender() { $markerImageTest = new MarkerImage(); $markerImageTest->setUrl('url'); $markerImageTest->setSize(new Size(1, 2)); $markerImageTest->setOrigin(new point(3, 4)); $markerImageTest->setAnchor(new Point(5, 6)); $markerImageTest->setScaledSize(new Size(7, 8)); $this->assertEquals(self::$markerImageHelper->render($markerImageTest), 'var ' . $markerImageTest->getJavascriptVariable() . ' = new google.maps.MarkerImage("url");' . PHP_EOL . $markerImageTest->getJavascriptVariable() . '.size = new google.maps.Size(1, 2);' . PHP_EOL . $markerImageTest->getJavascriptVariable() . '.origin = new google.maps.Point(3, 4);' . PHP_EOL . $markerImageTest->getJavascriptVariable() . '.anchor = new google.maps.Point(5, 6);' . PHP_EOL . $markerImageTest->getJavascriptVariable() . '.scaledSize = new google.maps.Size(7, 8);' . PHP_EOL); }
/** * Checks the render method */ public function testRender() { $mapTest = new Map(); $markerTest = new Overlays\Marker(); $markerTest->setPosition(new Base\Coordinate(1.1, 2.1, true)); $markerTest->setAnimation(Overlays\Animation::BOUNCE); $iconTest = new Overlays\MarkerImage(); $iconTest->setUrl('url'); $markerTest->setIcon($iconTest); $shadowTest = new Overlays\MarkerImage(); $shadowTest->setUrl('url'); $markerTest->setShadow($shadowTest); $shapeTest = new Overlays\MarkerShape(); $shapeTest->setType('poly'); $shapeTest->setCoordinates(array(1, 2, 3, 4)); $markerTest->setShape($shapeTest); $infoWindowTest = new Overlays\InfoWindow(); $infoWindowTest->setContent('content'); $markerTest->setInfoWindow($infoWindowTest); $this->assertEquals(self::$markerHelper->render($markerTest, $mapTest), 'var ' . $markerTest->getIcon()->getJavascriptVariable() . ' = new google.maps.MarkerImage("url");' . PHP_EOL . 'var ' . $markerTest->getShadow()->getJavascriptVariable() . ' = new google.maps.MarkerImage("url");' . PHP_EOL . 'var ' . $markerTest->getShape()->getJavascriptVariable() . ' = new google.maps.MarkerShape({"type":"poly","coords":[1,2,3,4]});' . PHP_EOL . 'var ' . $markerTest->getJavascriptVariable() . ' = new google.maps.Marker({"map":' . $mapTest->getJavascriptVariable() . ',"position":new google.maps.LatLng(1.1, 2.1, true), "animation":google.maps.Animation.BOUNCE, "icon":' . $markerTest->getIcon()->getJavascriptVariable() . ', "shadow":' . $markerTest->getShadow()->getJavascriptVariable() . ', "shape":' . $markerTest->getShape()->getJavascriptVariable() . '});' . PHP_EOL . 'var ' . $markerTest->getInfoWindow()->getJavascriptVariable() . ' = new google.maps.InfoWindow({"content":"content"});' . PHP_EOL); $markerTest->setOptions(array('option1' => 'value1', 'option2' => 'value2')); $this->assertEquals(self::$markerHelper->render($markerTest, $mapTest), 'var ' . $markerTest->getIcon()->getJavascriptVariable() . ' = new google.maps.MarkerImage("url");' . PHP_EOL . 'var ' . $markerTest->getShadow()->getJavascriptVariable() . ' = new google.maps.MarkerImage("url");' . PHP_EOL . 'var ' . $markerTest->getShape()->getJavascriptVariable() . ' = new google.maps.MarkerShape({"type":"poly","coords":[1,2,3,4]});' . PHP_EOL . 'var ' . $markerTest->getJavascriptVariable() . ' = new google.maps.Marker({"map":' . $mapTest->getJavascriptVariable() . ',"position":new google.maps.LatLng(1.1, 2.1, true), "animation":google.maps.Animation.BOUNCE, "icon":' . $markerTest->getIcon()->getJavascriptVariable() . ', "shadow":' . $markerTest->getShadow()->getJavascriptVariable() . ', "shape":' . $markerTest->getShape()->getJavascriptVariable() . ',"option1":"value1","option2":"value2"});' . PHP_EOL . 'var ' . $markerTest->getInfoWindow()->getJavascriptVariable() . ' = new google.maps.InfoWindow({"content":"content"});' . PHP_EOL); }
/** * Create a marker image */ public function __construct() { parent::__construct(); }
/** * Checks the shadow getter & setter */ public function testShadow() { self::$object->setShadow('url'); $this->assertEquals(self::$object->getShadow()->getUrl(), 'url'); $this->assertNull(self::$object->getShadow()->getAnchor()); $this->assertNull(self::$object->getShadow()->getOrigin()); $this->assertNull(self::$object->getShadow()->getScaledSize()); $this->assertNull(self::$object->getShadow()->getSize()); $markerImageTest = new MarkerImage(); $markerImageTest->setUrl('url'); self::$object->setShadow($markerImageTest); $this->assertEquals(self::$object->getShadow()->getUrl(), 'url'); $this->assertNull(self::$object->getShadow()->getAnchor()); $this->assertNull(self::$object->getShadow()->getOrigin()); $this->assertNull(self::$object->getShadow()->getScaledSize()); $this->assertNull(self::$object->getShadow()->getSize()); $markerImageTest = new MarkerImage(); $this->setExpectedException('InvalidArgumentException'); self::$object->setShadow($markerImageTest); $this->setExpectedException('InvalidArgumentException'); self::$object->setShadow(0); }
/** * 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); }