日期:2014-05-17 浏览次数:20555 次
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> html { height: 100% } body { height: 100%; margin: 0px; padding: 0px } #map_canvas { height: 100% } </style> <script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=true"> </script> <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> </head> <body onload="initialize()"> <form id="form1" runat="server"> <div id="map_canvas" style="width:100%; height:100%"></div> </form> </body> </html>
<form> //内容 </form> <div id="map_canvas" style="width:100%; height:100%"></div>
------解决方案--------------------
不是<form>的问题,我发的代码在div外加form也可以显示地图。
LZ不能正常显示地图的问题在于Div的样式,先给Div设置固定的宽高看一下效果就知道了
------解决方案--------------------
看看是不是跟百分比有关系