예제 #1
0
    public function testRenderJavascriptsWithInfoBox()
    {
        $this->mapHelper->setInfoWindowHelper(new InfoBoxHelper());
        $this->mapHelper->setExtensionHelper('info_box', new InfoBoxExtensionHelper());
        $map = new Map();
        $map->setJavascriptVariable('map');
        $map->getCenter()->setJavascriptVariable('map_center');
        $map->addInfoWindow($infoBox = new InfoWindow());
        $infoBox->setJavascriptVariable('map_info_box');
        $infoBox->setPosition(1, 2, true);
        $infoBox->getPosition()->setJavascriptVariable('map_info_box_position');
        $expected = <<<EOF
<script type="text/javascript">
function load_ivory_google_map_api () { google.load("maps", "3", {"other_params":"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" src="//google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/src/infobox_packed.js"></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.coordinates.map_info_box_position = map_info_box_position = new google.maps.LatLng(1, 2, true);
map_container.map = map = new google.maps.Map(document.getElementById("map_canvas"), {"mapTypeId":google.maps.MapTypeId.ROADMAP,"zoom":3});
map_container.info_windows.map_info_box = map_info_box = new InfoBox({"position":map_info_box_position,"content":"<p>Default content<\\/p>"});
map.setCenter(map_center);
</script>

EOF;
        $this->assertSame($expected, $this->mapHelper->renderJavascripts($map));
    }
 /**
  * @Route ("vertodos/")
  * @Template("YacareBaseBundle:DispositivoRastreadorGps:ver.html.twig")
  */
 public function vertodosAction(Request $request)
 {
     $em = $this->getEm();
     $Dispositivos = $em->getRepository('Yacare\\BaseBundle\\Entity\\DispositivoRastreadorGps')->findAll();
     $map = $this->CrearMapa();
     foreach ($Dispositivos as $Dispositivo) {
         $id = $Dispositivo->getId();
         $res = parent::verAction($request, $id);
         $entity = $res['entity'];
         if ($entity->getObs() == null) {
             $entity->setObs('Serie ' . $entity->getNumeroSerie());
         }
         $UltimoRastreo = $em->getRepository('Yacare\\BaseBundle\\Entity\\DispositivoRastreo')->findBy(array('Dispositivo' => $id), array('id' => 'DESC'), 1);
         if ($UltimoRastreo) {
             $UltimoRastreo = $UltimoRastreo[0];
             $map->addMarker($this->CrearMarcador($UltimoRastreo, $entity));
             // $map->setCenter($UltimoRastreo->getUbicacion()->getX(), $UltimoRastreo->getUbicacion()->getY(),
             // true);
         }
     }
     $mapHelper = new MapHelper();
     $mapHelper->setExtensionHelper('gps_extension_helper', new GpsExtensionHelper());
     $output = $mapHelper->renderJavascripts($map);
     $res['dispositivos'] = $Dispositivos;
     $res['js'] = $output;
     $res['map'] = $map;
     $res['uno'] = false;
     return $res;
 }