开发者

Can Google Maps API V3 be displayed in a table cell instead of a div?

Google Maps API V3 Developer's Guide provides us with a following default code:

<script type="text/javascript">
  function initialize() {
    var latlng = new google.maps.LatLng(-34.397, 150.644);
    var myOptions = {
      zoom: 8,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);
  }
</script>

and

<body onload="initialize()">
  <div id="map_canvas" style="width:100%; height:100%"></div>
</body>

However I would like my map to be displayed in a table cell instead of a div, like this:

<table>
 <tr>
  <td width="700px" height="700px" id="map_canvas"></td>
 </tr>
</table>

The map does not want to show the cod开发者_运维技巧e above. Is there a way to do it?


Is there a reason you can't put the div inside the table like:

<table> 
  <tr>  
    <td width="700px" height="700px">
      <div id="map_canvas" style="width:100%; height:100%"></div>
    </td>
  </tr>
</table>


The style has to be defined with width and height for the <div> element; otherwise, the div is zero-height, or so it seems. Mine didn't work until I put style='width:100%;height:100%' in there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜