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));
 }
Beispiel #3
0
 public function generateAction($address, $info_bulle = '', $width = '100%', $height = '100%')
 {
     $geocoder = new \Geocoder\Geocoder();
     $adapter = new \Geocoder\HttpAdapter\CurlHttpAdapter();
     $chain = new \Geocoder\Provider\ChainProvider(array(new \Geocoder\Provider\FreeGeoIpProvider($adapter), new \Geocoder\Provider\HostIpProvider($adapter), new \Geocoder\Provider\GoogleMapsProvider($adapter, 'fr_FR', 'France', true), new \Geocoder\Provider\BingMapsProvider($adapter, 'AIzaSyBZ3sNuoMPrXGCNbhnEbGmfzGxOohhEX4E')));
     $geocoder->registerProvider($chain);
     $address = urldecode($address);
     $info_bulle = urldecode($info_bulle);
     // Récupération des coordonnées du programme
     try {
         $coordonnees = $geocoder->geocode($address);
     } catch (ChainNoResultException $e) {
         try {
             $coordonnees = $geocoder->geocode('France');
         } catch (ChainNoResultException $e) {
             return false;
         }
     }
     $info_content = '<div style="min-width:150px;text-align:center;">' . $info_bulle . '</div>';
     $info_window = new InfoWindow();
     $info_window->setAutoOpen(true);
     $info_window->setOpen(true);
     $info_window->setContent($info_content);
     $marker = new Marker();
     $marker->setPosition($coordonnees->getLatitude(), $coordonnees->getLongitude(), true);
     $marker->setAnimation('drop');
     $marker->setOption('clickable', true);
     $marker->setOption('flat', true);
     if ($info_bulle) {
         $marker->setInfoWindow($info_window);
     }
     // Création de la map
     $map = new Map();
     $map->setPrefixJavascriptVariable('map_');
     $map->setHtmlContainerId('map_canvas');
     $map->setAsync(true);
     $map->setAutoZoom(false);
     $map->setCenter($coordonnees->getLatitude(), $coordonnees->getLongitude(), true);
     $map->setMapOption('zoom', 12);
     $map->setMapOption('mapTypeId', MapTypeId::ROADMAP);
     $map->setMapOption('disableDefaultUI', false);
     $map->setMapOption('disableDoubleClickZoom', false);
     $map->setStylesheetOption('width', $width);
     $map->setStylesheetOption('height', $height);
     $map->setLanguage('fr');
     $map->addMarker($marker);
     return $map;
 }
 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;
 }
    public function testRenderJavascriptsWithMarkerInfoWindowOpened()
    {
        $infoWindow = new InfoWindow();
        $infoWindow->setJavascriptVariable('info_window');
        $infoWindow->setContent('foo');
        $infoWindow->setAutoOpen(false);
        $infoWindow->setOpen(true);
        $marker = new Marker();
        $marker->setJavascriptVariable('marker');
        $marker->setPosition(1.2, 2.1, true);
        $marker->getPosition()->setJavascriptVariable('marker_position');
        $marker->setInfoWindow($infoWindow);
        $map = new Map();
        $map->setJavascriptVariable('map');
        $map->getCenter()->setJavascriptVariable('map_center');
        $map->addMarker($marker);
        $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">
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.marker_position = marker_position = new google.maps.LatLng(1.2, 2.1, true);
map_container.map = map = new google.maps.Map(document.getElementById("map_canvas"), {"mapTypeId":google.maps.MapTypeId.ROADMAP,"zoom":3});
map_container.info_windows.info_window = info_window = new google.maps.InfoWindow({"content":"foo"});
map_container.markers.marker = marker = new google.maps.Marker({"position":marker_position,"map":map});
info_window.open(map, marker);
map.setCenter(map_center);
</script>

EOF;
        $this->assertSame($expected, $this->mapHelper->renderJavascripts($map));
    }
 /**
  * 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;
 }
 /**
  * @expectedException \Ivory\GoogleMap\Exception\OverlayException
  * @expectedExceptionMessage The open property of an info window must be a boolean value.
  */
 public function testOpenWithInvalidValue()
 {
     $this->infoWindow->setOpen('foo');
 }
Beispiel #8
0
 /**
  * Render map with marker
  *
  * @param Coordinate $point
  * @param string     $info
  * @param bool       $async
  *
  * @return mixed
  * @throws \Ivory\GoogleMap\Exception\AssetException
  * @throws \Ivory\GoogleMap\Exception\MapException
  * @throws \Ivory\GoogleMap\Exception\OverlayException
  */
 public function renderMapWithMarker(Coordinate $point, string $info = '', bool $async = true) : array
 {
     $marker = new Marker();
     $infoWindow = new InfoWindow();
     $marker->setPrefixJavascriptVariable('marker_');
     $marker->setPosition($point);
     $marker->setAnimation(Animation::DROP);
     $marker->setOption('clickable', true);
     $marker->setOption('flat', true);
     if ($info) {
         $infoWindow->setPrefixJavascriptVariable('info_window_');
         $infoWindow->setContent("<p>{$info}</p>");
         $infoWindow->setOpen(false);
         $infoWindow->setAutoOpen(true);
         $marker->setInfoWindow($infoWindow);
     }
     $map = $this->createEmptyMap($point, $async);
     $map->setMapOption('zoom', 13);
     $map->addMarker($marker);
     return $this->renderMap($map);
 }