public function testRenderWithOptions()
 {
     $map = $this->getMock('Ivory\\GoogleMap\\Map');
     $map->expects($this->once())->method('getJavascriptVariable')->will($this->returnValue('map'));
     $encodedPolyline = new EncodedPolyline('foo');
     $encodedPolyline->setJavascriptVariable('encodedPolyline');
     $encodedPolyline->setOptions(array('option1' => 'value1', 'option2' => 'value2'));
     $this->assertSame('encodedPolyline = new google.maps.Polyline(' . '{"map":map,"path":google.maps.geometry.encoding.decodePath("foo"),"option1":"value1","option2":"value2"}' . ');' . PHP_EOL, $this->encodedPolylineHelper->render($encodedPolyline, $map));
 }
Пример #2
0
    public function testRenderJavascriptsWithEncodedPolyline()
    {
        $encodedPolyline = new EncodedPolyline('foo');
        $encodedPolyline->setJavascriptVariable('encoded_polyline');
        $map = new Map();
        $map->setJavascriptVariable('map');
        $map->addEncodedPolyline($encodedPolyline);
        $map->getCenter()->setJavascriptVariable('map_center');
        $expected = <<<EOF
<script type="text/javascript">
function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"libraries=geometry&language=en&sensor=false"}); };
</script>
<script type="text/javascript" src="//www.google.com/jsapi?callback=load_ivory_google_map_api"></script>
<script type="text/javascript">
map_container = {"map":null,"coordinates":{},"bounds":{},"points":{},"sizes":{},"circles":{},"encoded_polylines":{},"ground_overlays":{},"polygons":{},"polylines":{},"rectangles":{},"info_windows":{},"marker_images":{},"marker_shapes":{},"markers":{},"marker_cluster":null,"kml_layers":{},"event_manager":{"dom_events":{},"dom_events_once":{},"events":{},"events_once":{}},"closable_info_windows":{},"functions":{"to_array":function (object) { var array = []; for (var key in object) { array.push(object[key]); } return array; }}};
map_container.coordinates.map_center = map_center = new google.maps.LatLng(0, 0, true);
map_container.map = map = new google.maps.Map(document.getElementById("map_canvas"), {"mapTypeId":google.maps.MapTypeId.ROADMAP,"zoom":3});
map_container.encoded_polylines.encoded_polyline = encoded_polyline = new google.maps.Polyline({"map":map,"path":google.maps.geometry.encoding.decodePath("foo")});
map.setCenter(map_center);
</script>

EOF;
        $this->assertSame($expected, $this->mapHelper->renderJavascripts($map));
    }