public function testRenderWithOptions()
 {
     $map = $this->getMock('Ivory\\GoogleMap\\Map');
     $map->expects($this->once())->method('getJavascriptVariable')->will($this->returnValue('map'));
     $polygon = new Polygon();
     $polygon->setJavascriptVariable('polygon');
     $polygon->addCoordinate(1.1, 2.1);
     $polygon->addCoordinate(3.1, 4.2);
     $polygon->addCoordinate(7.4, 12.6);
     foreach ($polygon->getCoordinates() as $index => $coordinate) {
         $coordinate->setJavascriptVariable('coordinate' . $index);
     }
     $polygon->setOptions(array('option1' => 'value1', 'option2' => 'value2'));
     $expected = 'polygon = new google.maps.Polygon({' . '"map":map,' . '"paths":[' . 'coordinate0,' . 'coordinate1,' . 'coordinate2' . '],' . '"option1":"value1",' . '"option2":"value2"' . '});' . PHP_EOL;
     $this->assertSame($expected, $this->polygonHelper->render($polygon, $map));
 }
Ejemplo n.º 2
0
    public function testRenderJsContainerCoordinates()
    {
        $map = new Map();
        $map->setJavascriptVariable('map');
        $map->getCenter()->setJavascriptVariable('map_center');
        $map->addRectangle($rectangle = new Rectangle());
        $rectangle->getBound()->getSouthWest()->setJavascriptVariable('rectangle_south_west');
        $rectangle->getBound()->getNorthEast()->setJavascriptVariable('rectangle_north_east');
        $map->addCircle($circle = new Circle());
        $circle->getCenter()->setJavascriptVariable('circle_center');
        $map->addInfoWindow($infoWindow = new InfoWindow());
        $infoWindow->setPosition(1, 2, true);
        $infoWindow->getPosition()->setJavascriptVariable('info_window_position');
        $map->addMarker($marker = new Marker());
        $marker->getPosition()->setJavascriptVariable('marker_position');
        $map->addPolygon($polygon = new Polygon());
        $polygon->addCoordinate(1.1, 2.1);
        $polygon->addCoordinate(3.1, 4.2);
        foreach ($polygon->getCoordinates() as $index => $polygonCoordinate) {
            $polygonCoordinate->setJavascriptVariable('polygon_coordinate_' . $index);
        }
        $map->addPolyline($polyline = new Polyline());
        $polyline->addCoordinate(1.2, 2.6);
        $polyline->addCoordinate(3.2, 4.9);
        foreach ($polyline->getCoordinates() as $index => $polyline) {
            $polyline->setJavascriptVariable('polyline_coordinate_' . $index);
        }
        $expected = <<<EOF
map_container.coordinates.map_center = map_center = new google.maps.LatLng(0, 0, true);
map_container.coordinates.rectangle_south_west = rectangle_south_west = new google.maps.LatLng(-1, -1, true);
map_container.coordinates.rectangle_north_east = rectangle_north_east = new google.maps.LatLng(1, 1, true);
map_container.coordinates.circle_center = circle_center = new google.maps.LatLng(0, 0, true);
map_container.coordinates.info_window_position = info_window_position = new google.maps.LatLng(1, 2, true);
map_container.coordinates.marker_position = marker_position = new google.maps.LatLng(0, 0, true);
map_container.coordinates.polygon_coordinate_0 = polygon_coordinate_0 = new google.maps.LatLng(1.1, 2.1, true);
map_container.coordinates.polygon_coordinate_1 = polygon_coordinate_1 = new google.maps.LatLng(3.1, 4.2, true);
map_container.coordinates.polyline_coordinate_0 = polyline_coordinate_0 = new google.maps.LatLng(1.2, 2.6, true);
map_container.coordinates.polyline_coordinate_1 = polyline_coordinate_1 = new google.maps.LatLng(3.2, 4.9, true);

EOF;
        $this->assertSame($expected, $this->mapHelper->renderJsContainerCoordinates($map));
    }
Ejemplo n.º 3
0
 /**
  * @expectedException \Ivory\GoogleMap\Exception\OverlayException
  * @expectedExceptionMessage The coordinate adder arguments is invalid.
  * The available prototypes are :
  * - function addCoordinate(Ivory\GoogleMap\Base\Coordinate $coordinate)
  * - function addCoordinate(double $latitude, double $longitude, boolean $noWrap = true)
  */
 public function testCoordinateWithInvalidValue()
 {
     $this->polygon->addCoordinate('foo');
 }