-1

我想在我的网页中显示谷歌地图,但它没有显示在我的网页中,我无法修复错误是什么,我尝试了不同的方法,但地图区域仍然看起来空白......所以请帮助我修复错误。 ...对不起我的英语不好

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&key=AIzaSyA39kFEuPToMAHcpdQzzpZFmpyENv9MT_A&sensor=false"></script>
    <script>
var map;
function initialize() {
  var mapOptions = {
    zoom: 8,
    center: new google.maps.LatLng(-34.397, 150.644),
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  map = new google.maps.Map(document.getElementById('map-canvas'),
      mapOptions);
}

google.maps.event.addDomListener(window, 'load', initialize);

    </script>
<form action="<?php echo $_SERVER["PHP_SELF"];?>" method="post" onSubmit="return check_add_form();">
<table width="100%" border="0" class="details">
  <tr>
    <th colspan="2" align="left" nowrap="nowrap" class="top-heading">Map Location</th>
    </tr>
  <tr>
    <th width="22%" align="left" valign="top" nowrap="nowrap" class="heading">Address: </th>
    <td width="78%" align="left" valign="top"> <input type="text" id="Location_Address" name="Location_Address" value="<?php echo stripslashes($Location_Address);?>"/>
      <span class="red">*</span></td>
  </tr>
  <tr>
    <td colspan="2" align="left" valign="top" nowrap="nowrap">
    <input type="hidden" id="Latitude" name="Latitude" value="<?php echo stripslashes($Latitude);?>"/>
    <input type="hidden" id="Longitude" name="Longitude" value="<?php echo stripslashes($Longitude);?>"/>
    <div id="map-canvas"></div>
    </td>
    </tr>
  <tr>
    <th  nowrap="nowrap"></th><td align="left" valign="top"><span id="message" class="red"><?php echo $message;?></span><br />
      <input type="submit" name="submit" value="Save"/></td>
  </tr>
</table>
<div id="googleMap" style="width:500px;height:380px;"></div>
</form>
`

提前致谢....

4

1 回答 1

2

在文档头部使用以下代码

    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&key=AIzaSyA39kFEuPToMAHcpdQzzpZFmpyENv9MT_A&sensor=false"></script>
        <script>
    var map;
    function initialize() {
      var mapOptions = {
        zoom: 8,
        center: new google.maps.LatLng(-34.397, 150.644),
        mapTypeId: google.maps.MapTypeId.ROADMAP
      };
      map = new google.maps.Map(document.getElementById('map-canvas'),
          mapOptions);
    }

    google.maps.event.addDomListener(window, 'load', initialize);

</script>

并使用

<div id="googleMap" style="width:500px;height:380px;"></div>

在您文档的任何位置

于 2013-06-24T13:47:18.230 回答