public function testInitialState() { $southWest = $this->getMock('Ivory\\GoogleMap\\Base\\Coordinate'); $northEast = $this->getMock('Ivory\\GoogleMap\\Base\\Coordinate'); $extends = array($this->getMock('Ivory\\GoogleMap\\Overlays\\ExtendableInterface')); $this->bound = new Bound($southWest, $northEast, $extends); $this->assertTrue($this->bound->hasCoordinates()); $this->assertSame($southWest, $this->bound->getSouthWest()); $this->assertSame($northEast, $this->bound->getNorthEast()); $this->assertTrue($this->bound->hasExtends()); $this->assertSame($extends, $this->bound->getExtends()); }
/** * Renders the bound's extend of a marker. * * @param \Ivory\GoogleMap\Base\Bound $bound The bound. * * @return string The JS output. */ public function renderExtends(Bound $bound) { $output = array(); foreach ($bound->getExtends() as $extend) { if ($extend instanceof Marker || $extend instanceof InfoWindow) { $output[] = sprintf('%s.extend(%s.getPosition());' . PHP_EOL, $bound->getJavascriptVariable(), $extend->getJavascriptVariable()); } elseif ($extend instanceof Polyline || $extend instanceof EncodedPolyline || $extend instanceof Polygon) { $output[] = sprintf('%s.getPath().forEach(function(element){%s.extend(element)});' . PHP_EOL, $extend->getJavascriptVariable(), $bound->getJavascriptVariable()); } elseif ($extend instanceof Rectangle || $extend instanceof GroundOverlay) { $output[] = sprintf('%s.union(%s);' . PHP_EOL, $bound->getJavascriptVariable(), $extend->getBound()->getJavascriptVariable()); } elseif ($extend instanceof Circle) { $output[] = sprintf('%s.union(%s.getBounds());' . PHP_EOL, $bound->getJavascriptVariable(), $extend->getJavascriptVariable()); } } return implode('', $output); }