コード例 #1
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));
    }