如何使用static Resources for infowindow setContent?

时间:2013-09-16 14:24:27

标签: javascript google-maps

在标记处使用图像时,我在谷歌地图上获取图像,但是当我在infowindow使用相同的图像时,它只显示网址。

代码:

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}”在infowindow上显示谷歌地图的图像。 任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

如果{!$Resource.Image_GoogleMap}是图片的网址,并且您想在InfoWindow中显示它,请使用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>';