google map不能在form里边显示

todayq 2012-10-22 01:43:06
<%@ 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>标签后可以显示地图。但是呢会影响ajaxpro的使用,怎么样才能把地图显示在form里边呢?求解!
...全文
178 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
紫魂一号 2012-10-23
  • 打赏
  • 举报
回复
看看是不是跟百分比有关系
rabbit5 2012-10-23
  • 打赏
  • 举报
回复
不是<form>的问题,我发的代码在div外加form也可以显示地图。

LZ不能正常显示地图的问题在于Div的样式,先给Div设置固定的宽高看一下效果就知道了
todayq 2012-10-23
  • 打赏
  • 举报
回复
发现问题所在了,原来我把那个样式弄丢了,谢谢各位啦!
todayq 2012-10-22
  • 打赏
  • 举报
回复
我希望能够将<div id="map-canvas" style="width: 500px; height: 400px"></div>
放在<form>里边
rabbit5 2012-10-22
  • 打赏
  • 举报
回复
几天没用都到V3了,真是落后呀

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps V3 API Sample</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">

function initialize() {
var mapDiv = document.getElementById('map-canvas');
var map = new google.maps.Map(mapDiv, {
center: new google.maps.LatLng(37.4419, -122.1419),
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
}


google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body style="font-family: Arial; border: 0 none;">
<div id="map-canvas" style="width: 500px; height: 400px"></div>
</body>
</html>
todayq 2012-10-22
  • 打赏
  • 举报
回复
哎,一做交互还是不能显示出地图呀
  • 打赏
  • 举报
回复
试了下不行的,这样不就行了。。。

<form>
//内容
</form>
<div id="map_canvas" style="width:100%; height:100%"></div>
  • 打赏
  • 举报
回复
没用过,试下把runat="server"去掉

62,047

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧