2013-09-16 62 views
0

我在谷歌地圖上使用圖像標記時獲取圖像,但是當我爲infowindow使用相同圖像時,它只顯示url。如何使用靜態資源infowindow setContent?

代碼:

var content = '<div class="map-content"><h3>' + "Account Name: " + "{!acc.Name} " + 
    '</h3>' + '<b>' +"Location: " + "{!acc.BillingCity}" + '</b>' + '</br>' +   
    "Direction : " + '<a href="http://maps.google.com/?daddr=' + "{!acc.BillingCity}" + 
    '" target="_blank">Get Directions</a>' + "{!$Resource.Image_GoogleMap}" +'</div>'; 

        google.maps.event.addListener(marker, 'mouseover', function() { 
         infowindow.open(map, this); 
         infowindow.setContent(content); 
        }); 

如何使用 「{$ Resource.Image_GoogleMap!}」,以顯示在信息窗口的谷歌地圖圖像。 任何人都可以幫助我嗎?

+0

什麼是''{!$ Resource.Image_GoogleMap}''? –

+0

感謝Joni的快速回復。是的,這是一個圖像的URL,現在它的工作正常,並在infowindow中顯示圖像。 – DINESH

回答

0

如果{!$Resource.Image_GoogleMap}是圖像的URL,並且要在信息窗口中顯示它,使用normal HTM L:

<img src="{!$Resource.Image_GoogleMap}" alt="image description"> 

(注意匹配「和」正確地)

var content = '<div class="map-content"><h3>' + "Account Name: " + "{!acc.Name} " + 
'</h3>' + '<b>' +"Location: " + "{!acc.BillingCity}" + '</b>' + '</br>' +   
"Direction : " + '<a href="http://maps.google.com/?daddr=' + "{!acc.BillingCity}" + 
'" target="_blank">Get Directions</a>' + '<img src="{!$Resource.Image_GoogleMap}" alt="image description">' +'</div>';