Google maps infowindow not showing when clicking on Symfony2 using VichGeographicalBundle

I have successfully configured the VichGeographicalBundle to display a bunch of places on a Google map. Everything works fine, with the exception of info windows that are not displayed when clicked.

$this->setShowInfoWindowsForMarkers(true); installed but doesn't seem to work.

Any ideas?

EDIT:

 class allShopsMap extends Map { /** * Constructs a new instance of LocationMap. */ public function __construct(EntityManager $em) { parent::__construct(); // configure your map in the constructor // by setting the options $this->setShowZoomControl(true); $this->setZoom(13); $this->setAutoZoom(false); $this->setContainerId('map_canvas'); $this->setWidth(980); $this->setHeight(360); $this->setShowInfoWindowsForMarkers(true); $this->setCenter(23.232323,23.232323); $this->setShowMapTypeControl(true); $query = $em->createQuery("SELECT st FROM acme\ShopBundle\Entity\Shop sh WHERE sh.published = 1 "); $shops = $query->getResult(); foreach ($shops as $shop) { $this->addMarker(new MapMarker($shop->getLatitude(), $shop->getLongitude(),$icon='images/map_marker.png')); } } } 

Called from the branch template:

 {{ vichgeo_map('allShops') }} 

config.yml

 vich_geographical: db_driver: orm query_service: vich_geographical.query_service.default map_renderer: vich_geographical.map_renderer.google templating: engine: twig info_window: msgrShopBundle:Map:infoWindow.html.twig services: msgr.map.allShops: class: msgr\ShopBundle\Map\allShopsMap tags: - { name: vichgeo.map, alias: allShops } arguments: entityManager: "@doctrine.orm.entity_manager" 

HTML code generated by {{ vichgeo_map('allShops') }} : http://pastebin.com/jqvzG67N

+4
source share
1 answer

Try the following:

 class allShopsMap extends Map { /** * Constructs a new instance of LocationMap. */ public function __construct(EntityManager $em, $infoWindowBuilder) { parent::__construct(); // configure your map in the constructor // by setting the options $this->setShowZoomControl(true); $this->setZoom(13); $this->setAutoZoom(false); $this->setContainerId('map_canvas'); $this->setWidth(980); $this->setHeight(360); $this->setShowInfoWindowsForMarkers(true); $this->setCenter(23.232323,23.232323); $this->setShowMapTypeControl(true); $query = $em->createQuery("SELECT st FROM acme\ShopBundle\Entity\Shop sh WHERE sh.published = 1 "); $shops = $query->getResult(); foreach ($shops as $shop) { $marker = new MapMarker($shop->getLatitude(), $shop->getLongitude(),$icon='images/map_marker.png'); $marker->setInfoWindow($infoWindowBuilder->build($marker)); $this->addMarker($marker); } } } 

infoWindowBuilder is a vich_geographical.info_window_builder service available in a container.

And change your configuration:

 services: msgr.map.allShops: class: msgr\ShopBundle\Map\allShopsMap tags: - { name: vichgeo.map, alias: allShops } arguments: entityManager: "@doctrine.orm.entity_manager" infoWindowBuilder: "@vich_geographical.info_window_builder" 
+1
source

All Articles