《 Google Maps API V3开发人员指南》为我们提供了以下默认代码:

<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>


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

但是我希望 map 显示在表格单元格而不是div中,如下所示:
<table>
 <tr>
  <td width="700px" height="700px" id="map_canvas"></td>
 </tr>
</table>

map 不希望显示上面的代码。有办法吗?

最佳答案

有没有理由不能将div放在表中,例如:

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

09-25 18:32
查看更多