2011-09-05 52 views
1

我試圖用IvoryGoogleMap顯示簡單的地圖使用此代碼標記和信息窗口:IvoryGoogleMap - 無法顯示信息窗口

$marker  ->setPosition($place->getLat(), $place->getLng()); 
$infoWindow ->setContent('<p>Default content</p>'); 
$marker  ->setInfoWindow($infoWindow); 
$map  ->addMarker($marker); 

和所有我得到的是帶有標記的地圖(S )但是當我點擊其中一個時,什麼也沒有發生。你有什麼想法我做錯了什麼?

回答

1

好的,問題解決了。下面是包的作者egeloen解決方案(上github):

=============================== =======================================

此功能本身不存在。如果您想通過標記上的單擊事件打開信息窗口,則需要使用ivory_google_map.event服務。該服務允許您生成您想要的所有事件。

在你的情況,該事件是:

$clickEvent = $this->get('ivory_google_map.event'); 
$clickEvent->setInstance($marker->getJavascriptVariable()); 
$clickEvent->setEventName('click'); 
$clickEvent->setHandle(sprintf('function(){%s.open(%s, %s);}', 
    $infoWindow->getJavascriptVariable(), 
    $map->getJavascriptVariable(), 
    $marker->getJavascriptVariable() 
); 

$map->getEventManager()->addEvent($clickEvent);