-1
我想显示谷歌地图在我的网页,但它不显示在我的网页,我无法修复错误是什么,我尝试了不同的方法,但仍然地图区域看起来空白...所以请大家帮我修正这个错误....对不起,事先我的英语谷歌地图api v3不显示
<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>
`
感谢....
您是否尝试过检查控制台或者Chrome或Safari浏览器,以查看是否正在抛出的任何JavaScript错误? –
@MartinBean没有错误,但它没有显示任何东西... – sarincm99
这是一个常见问题。你的地图div没有大小。 [具有固定大小的示例](http://www.geocodezip.com/v3_SO_simpleMap_wontDisplay.html) – geocodezip