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; }
/** * 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; }
/** * 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)); }