2011-05-03 81 views
0

如何增加我通過地址的infowindow的高度?它在IE8和Firefox的Windows 7中正確顯示,但在Windows XP中,地址部分位於infowindow之外。如何增加Google Maps API中infowindow的高度?

function initialize() { 
      if (GBrowserIsCompatible()) { 
      var map = new GMap2(document.getElementById("map_canvas"), 
         { size: new GSize(400,300) }); 
      map.setCenter(new GLatLng(23.027527,72.508223), 13); 
      var point = new GLatLng(23.027527,72.508223); 
      var html_text = "<table cellspacing=0 cellpadding=0><tr><td><b><font size=-1px>hi</font></b></td></tr><tr><td><font size=-2px>hisdf,</font></td></tr><tr><td><font size=-2px>hisdf</font></td></tr><tr><td><font size=-2px>hisdfs</font></td></tr></table>"; 
      var marker = new GMarker(point, G_DEFAULT_ICON); 
      map.addOverlay(marker); 
      marker.openInfoWindowHtml(html_text); 
      GEvent.addListener(marker, "mouseover", function() { 
       marker.openInfoWindowHtml(html_text); 
      }); 

      map.enableScrollWheelZoom(); 

      var customUI = map.getDefaultUI(); 
      customUI.controls.scalecontrol = false; 
      map.setUI(customUI); 
      } 
} 

這是我的代碼,你我怎麼可以在功能應用DIV可以建議我嗎?

谷歌地圖API樣品

function initialize() { 
       if (GBrowserIsCompatible()) { 
       var map = new GMap2(document.getElementById("map_canvas"), 
     { size: new GSize(400,300) }); 
       map.setCenter(new GLatLng(23.027527,72.508223), 13); 
       var point = new GLatLng(23.027527,72.508223); 
       var html_text = "<table cellspacing=0 cellpadding=0><tr><td><b><font size=-1px>Cadila Healthcare Ltd</font></b></td></tr><tr><td><font size=-2px>Satellite Cross Roads, Ahmedabad,</font></td></tr><tr><td><font size=-2px>Gujarat, India, 380015</font></td></tr><tr><td><font size=-2px>Phone : 79-26868100</font></td></tr></table>"; 
       var marker = new GMarker(point, G_DEFAULT_ICON); 
       map.addOverlay(marker); 
       marker.openInfoWindowHtml(html_text); 
       GEvent.addListener(marker, "mouseover", function() { 
          marker.openInfoWindowHtml(html_text); 
         }); 


       map.enableScrollWheelZoom(); 

       var customUI = map.getDefaultUI(); 
       customUI.controls.scalecontrol = false; 
       map.setUI(customUI); 

       } 
    } 


</script> 

+0

看一看這個鏈接http://apps.ndtv.com/maps/election。檢查infoWindow的大小 – 2011-05-03 14:17:15

回答

0
function initialize() { 
      if (GBrowserIsCompatible()) { 
      var map = new GMap2(document.getElementById("map_canvas"), 
    { size: new GSize(400,300) }); 
      map.setCenter(new GLatLng(23.027527,72.508223), 13); 
      var point = new GLatLng(23.027527,72.508223); 
           var html = "<table width=\"100%\" border=\"0\" cellpadding=\"0\"cellspacing=\"0\">"; 
        html += "<tr><td><b><font size=-1px>dfgd</font></b></td></tr>"; 
        html += "<tr><td><font size=-2px>dfgdg</font></td></tr>"; 
        html += "<tr><td><font size=-2px>dfgdg</font></td></tr>"; 
        html += "<tr><td><font size=-2px>fdgdgd</font></td></tr>"; 
        html += "</table>"; 
        html = "<div style=\"position: relative; float: left; width: 225px; height: 80px; border: 0px coral solid;\">" + html + "</div>"; 
      var marker = new GMarker(point, G_DEFAULT_ICON); 
      map.addOverlay(marker); 
      marker.openInfoWindowHtml(html); 
      GEvent.addListener(marker, "mouseover", function() { 
         marker.openInfoWindowHtml(html); 
        }); 


      map.enableScrollWheelZoom(); 

      var customUI = map.getDefaultUI(); 
      customUI.controls.scalecontrol = false; 
      map.setUI(customUI); 

      } 
} 

你可以使用這樣的HTML ....

0

首先,我強烈建議您不要在變量的方式使用HTML。這真的很難閱讀,並可能使您暴露於XSS攻擊。改爲使用DOM中正確的html元素。

<div id="myTemplates" style="display:none"> 
<table cellspacing=0 cellpadding=0> 
    <tr> 
     <td><b><font size=-1px>hi</font></b></td> 
    </tr> 
    <tr> 
     <td><font size=-2px>hisdf,</font></td> 
    </tr> 
    <tr> 
     <td><font size=-2px>hisdf</font></td> 
    </tr> 
    <tr> 
     <td><font size=-2px>hisdfs</font></td> 
    </tr> 
</table> 
</div> 

$('#myTemplate table').clone(); 

得到的元素。

那麼當然你會想把樣式從內聯改爲CSS,這樣可以更容易地看到它有什麼問題以及社區的幫助。 :-)

然後回到你的問題:它看起來像生成的彈出窗口中的一個容器元素具有在元素中指定的寬度和高度。

<div style="position: relative; left: 0px; top: 0px; z-index: 10; width: 249px; height: 90px;" class="gmnoprint"> 

這可能是您的內容不適合的原因。 IE和FF以不同的方式處理拳擊。

相關問題