php – 谷歌地图infowindow没有显示在使用VichGeographicalBundl
发布时间:2020-12-13 22:47:00 所属栏目:PHP教程 来源:网络整理
导读:我已成功设置 VichGeographicalBundle以在Google地图中显示一堆地点.一切正常,除了点击时没有显示的信息窗口. $这 – setShowInfoWindowsForMarkers(真);设置但似乎不起作用. 有任何想法吗 ? 编辑: class allShopsMap extends Map{ /** * Constructs a new
我已成功设置
VichGeographicalBundle以在Google地图中显示一堆地点.一切正常,除了点击时没有显示的信息窗口.
$这 – > setShowInfoWindowsForMarkers(真);设置但似乎不起作用. 有任何想法吗 ? 编辑: 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 acmeShopBundleEntityShop 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')); } } } 从树枝模板调用: {{ 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: msgrShopBundleMapallShopsMap tags: - { name: vichgeo.map,alias: allShops } arguments: entityManager: "@doctrine.orm.entity_manager" 由{{vichgeo_map(‘allShops’)}}生成的HTML代码:http://pastebin.com/jqvzG67N 解决方法
试试这个:
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 acmeShopBundleEntityShop sh WHERE sh.published = 1 "); $shops = $query->getResult(); foreach ($shops as $shop) { $marker = new MapMarker($shop->getLatitude(),$icon='images/map_marker.png'); $marker->setInfoWindow($infoWindowBuilder->build($marker)); $this->addMarker($marker); } } } infoWindowBuilder是容器中可用的vich_geographical.info_window_builder服务. 并修改您的配置: services: msgr.map.allShops: class: msgrShopBundleMapallShopsMap tags: - { name: vichgeo.map,alias: allShops } arguments: entityManager: "@doctrine.orm.entity_manager" infoWindowBuilder: "@vich_geographical.info_window_builder" (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |