public function testRender()
 {
     $infoWindow = new InfoWindow();
     $infoWindow->setPosition(1.1, 2.1, true);
     $infoWindow->getPosition()->setJavascriptVariable('position');
     $infoWindow->setPixelOffset(3, 4, 'px', 'px');
     $infoWindow->getPixelOffset()->setJavascriptVariable('pixel_offset');
     $infoWindow->setContent('content');
     $infoWindow->setOpen(true);
     $infoWindow->setOptions(array('option1' => 'value1', 'option2' => 'value2'));
     $expected = $infoWindow->getJavascriptVariable() . ' = new InfoBox({' . '"position":position,' . '"pixelOffset":pixel_offset,' . '"content":"content",' . '"option1":"value1",' . '"option2":"value2"' . '});' . PHP_EOL;
     $this->assertSame($expected, $this->infoBoxHelper->render($infoWindow, true));
 }
 public function testRenderOpenWithMarker()
 {
     $map = $this->getMock('Ivory\\GoogleMap\\Map');
     $map->expects($this->once())->method('getJavascriptVariable')->will($this->returnValue('map'));
     $infoWindow = new InfoWindow();
     $infoWindow->setJavascriptVariable('infoWindow');
     $infoWindow->setPosition(1.1, 2.1, true);
     $infoWindow->setContent('content');
     $infoWindow->setOpen(true);
     $infoWindow->setOptions(array('option1' => 'value1', 'option2' => 'value2'));
     $marker = $this->getMock('Ivory\\GoogleMap\\Overlays\\Marker');
     $marker->expects($this->once())->method('getJavascriptVariable')->will($this->returnValue('marker'));
     $this->assertSame('infoWindow.open(map, marker);' . PHP_EOL, $this->infoWindowHelper->renderOpen($infoWindow, $map, $marker));
 }
 protected function getGoogleMapMarkerInfo($markerContent)
 {
     $infoWindow = new InfoWindow();
     // Configure the info window options
     $infoWindow->setPrefixJavascriptVariable('info_window_');
     $infoWindow->setPosition(0, 0, true);
     $infoWindow->setPixelOffset(1.1, 2.1, 'px', 'pt');
     $infoWindow->setContent($markerContent);
     $infoWindow->setOpen(false);
     $infoWindow->setAutoOpen(true);
     $infoWindow->setOpenEvent(MouseEvent::CLICK);
     $infoWindow->setAutoClose(false);
     $infoWindow->setOption('disableAutoPan', true);
     $infoWindow->setOption('zIndex', 10);
     $infoWindow->setOptions(array('disableAutoPan' => true, 'zIndex' => 10));
     return $infoWindow;
 }
예제 #4
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));
    }
예제 #5
0
 /**
  * Crée une fenêtre d'information pour un marker
  * @param $fiche, la fiche pour laquelle il créer une fenêtre d'informations
  * @return InfoWindow
  * @throws \Ivory\GoogleMap\Exception\AssetException
  * @throws \Ivory\GoogleMap\Exception\OverlayException
  */
 public function InfoWindowMarker($fiche)
 {
     $infoWindow = new InfoWindow();
     $infoWindow->setPrefixJavascriptVariable('info_window_');
     $infoWindow->setPosition($fiche->getLatitude(), $fiche->getLongitude(), true);
     $infoWindow->setPixelOffset(1.1, 2.1, 'px', 'pt');
     $infoWindow->setOpen(false);
     $infoWindow->setAutoOpen(true);
     $infoWindow->setOpenEvent('mouseover');
     $infoWindow->setAutoClose(true);
     $infoWindow->setOption('disableAutoPan', true);
     $infoWindow->setOptions(array('disableAutoPan' => true, 'zIndex' => 10));
     return $infoWindow;
 }
예제 #6
0
 /**
  * @expectedException \Ivory\GoogleMap\Exception\OverlayException
  * @expectedExceptionMessage The position setter arguments is invalid.
  * The available prototypes are :
  * - function setPosition(Ivory\GoogleMap\Base\Coordinate $position)
  * - function setPosition(double $latitude, double $longitude, boolean $noWrap = true)
  */
 public function testPositionWithInvalidValue()
 {
     $this->infoWindow->setPosition('foo');
 }
예제 #7
0
 /**
  * Render a Google Map in an iframe. If $identifier is specified then a small map will be output with a single
  * marker. Otherwise a large map will be output with a marker for each venue.
  *
  * @param null|string $identifier
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function mapAction($identifier = null)
 {
     $repo = $this->getDoctrine()->getManager()->getRepository('ActsCamdramBundle:Venue');
     if ($identifier) {
         $venues = array($repo->findOneBySlug($identifier));
     } else {
         $venues = $repo->findAllOrderedByName();
     }
     $map = $this->get('ivory_google_map.map');
     $map->setPrefixJavascriptVariable('map_');
     $map->setHtmlContainerId('map_canvas');
     $map->setStylesheetOptions(array('width' => '100%', 'height' => '100%'));
     $one_venue = count($venues) == 1;
     if ($one_venue) {
         $map->setMapOption('zoom', 16);
         $map->setCenter($venues[0]->getLatitude(), $venues[0]->getLongitude(), true);
     } else {
         $map->setMapOption('zoom', 14);
         $map->setCenter(52.20531, 0.12179, true);
     }
     $letter = ord('A');
     $info_boxes = array();
     foreach ($venues as $venue) {
         if ($venue->getLatitude() && $venue->getLongitude()) {
             $content = $this->render('ActsCamdramBundle:Venue:infobox.html.twig', array('venue' => $venue, 'one_venue' => $one_venue))->getContent();
             $infoWindow = new InfoWindow();
             $infoWindow->setPrefixJavascriptVariable('info_window_');
             $infoWindow->setPosition($venue->getLatitude(), $venue->getLongitude(), true);
             $infoWindow->setContent($content);
             $infoWindow->setAutoOpen(true);
             $infoWindow->setOpenEvent(MouseEvent::CLICK);
             $infoWindow->setAutoClose(true);
             $infoWindow->setOption('zIndex', 10);
             $map->addInfoWindow($infoWindow);
             $marker = new Marker();
             $marker->setPrefixJavascriptVariable('marker_');
             $marker->setPosition($venue->getLatitude(), $venue->getLongitude(), true);
             if ($one_venue) {
                 $marker->setIcon($this->getMarkerUrl(''));
             } else {
                 $marker->setIcon($this->getMarkerUrl(chr($letter)));
             }
             $marker->setInfoWindow($infoWindow);
             $marker->setOption('clickable', true);
             $map->addMarker($marker);
             $info_boxes[] = array('image' => $this->getMarkerUrl(chr($letter)), 'box_id' => $infoWindow->getJavascriptVariable(), 'marker_id' => $marker->getJavascriptVariable(), 'map_id' => $map->getJavascriptVariable(), 'slug' => $venue->getSlug());
             $letter++;
             if ($letter == ord('Z') + 1) {
                 $letter = ord('A');
             }
         }
     }
     return $this->render('ActsCamdramBundle:Venue:map.html.twig', array('map' => $map, 'info_boxes' => $info_boxes));
 }