示例#1
0
 /**
  * Renders the js container extra.
  *
  * @param \Ivory\GoogleMap\Map $map The map.
  *
  * @return string The JS output.
  */
 public function renderJsContainerExtra(Map $map)
 {
     $output = array();
     foreach ($map->getInfoWindows() as $infoWindow) {
         if ($infoWindow->isOpen()) {
             $output[] = $this->infoWindowHelper->renderOpen($infoWindow, $map);
         }
     }
     foreach ($map->getMarkers() as $marker) {
         if ($marker->hasInfoWindow() && $marker->getInfoWindow()->isOpen()) {
             $output[] = $this->infoWindowHelper->renderOpen($marker->getInfoWindow(), $map, $marker);
         }
     }
     foreach ($this->computeBounds($map) as $bound) {
         if ($bound->hasExtends()) {
             $output[] = $this->boundHelper->renderExtends($bound);
         }
     }
     if ($map->isAutoZoom()) {
         $output[] = $this->renderMapBound($map);
     } else {
         $output[] = $this->renderMapCenter($map);
     }
     return implode('', $output);
 }
    public function testRenderExtends()
    {
        $bound = new Bound();
        $bound->setJavascriptVariable('bound');
        $circle = $this->getMock('Ivory\\GoogleMap\\Overlays\\Circle');
        $circle->expects($this->once())->method('getJavascriptVariable')->will($this->returnValue('circle'));
        $groundOverlayBound = $this->getMock('Ivory\\GoogleMap\\Base\\Bound');
        $groundOverlayBound->expects($this->once())->method('getJavascriptVariable')->will($this->returnValue('groundOverlayBound'));
        $groundOverlay = $this->getMock('Ivory\\GoogleMap\\Overlays\\GroundOverlay');
        $groundOverlay->expects($this->once())->method('getBound')->will($this->returnValue($groundOverlayBound));
        $infoWindow = $this->getMock('Ivory\\GoogleMap\\Overlays\\InfoWindow');
        $infoWindow->expects($this->once())->method('getJavascriptVariable')->will($this->returnValue('infoWindow'));
        $marker = $this->getMock('Ivory\\GoogleMap\\Overlays\\Marker');
        $marker->expects($this->once())->method('getJavascriptVariable')->will($this->returnValue('marker'));
        $polygon = $this->getMock('Ivory\\GoogleMap\\Overlays\\Polygon');
        $polygon->expects($this->once())->method('getJavascriptVariable')->will($this->returnValue('polygon'));
        $polyline = $this->getMock('Ivory\\GoogleMap\\Overlays\\Polyline');
        $polyline->expects($this->once())->method('getJavascriptVariable')->will($this->returnValue('polyline'));
        $rectangleBound = $this->getMock('Ivory\\GoogleMap\\Base\\Bound');
        $rectangleBound->expects($this->once())->method('getJavascriptVariable')->will($this->returnValue('rectangleBound'));
        $rectangle = $this->getMock('Ivory\\GoogleMap\\Overlays\\Rectangle');
        $rectangle->expects($this->once())->method('getBound')->will($this->returnValue($rectangleBound));
        $bound->extend($circle);
        $bound->extend($groundOverlay);
        $bound->extend($infoWindow);
        $bound->extend($marker);
        $bound->extend($polygon);
        $bound->extend($polyline);
        $bound->extend($rectangle);
        $expected = <<<EOF
bound.union(circle.getBounds());
bound.union(groundOverlayBound);
bound.extend(infoWindow.getPosition());
bound.extend(marker.getPosition());
polygon.getPath().forEach(function(element){bound.extend(element)});
polyline.getPath().forEach(function(element){bound.extend(element)});
bound.union(rectangleBound);

EOF;
        $this->assertSame($expected, $this->boundHelper->renderExtends($bound));
    }