【发布时间】:2015-07-03 23:37:19
【问题描述】:
我的aspx页面内容是这样的
<body>
<div id="mapDiv"></div>
<form id="form" runat="server"></form>
</body>
并在代码隐藏中创建脚本
string script = string.Format(@"function initialize() {{
var mapOptions = {{
center: new google.maps.LatLng({0},{1}),
zoom: 8,
tilt: 30
}};
var map = new google.maps.Map(document.getElementById('mapDiv'), mapOptions);
{2}
}}
function addInfoWindow(marker, content) {{
var infoWindow = new google.maps.InfoWindow({{
content: content
}});
google.maps.event.addListener(marker, 'click', function () {{
if (currentInfoWindow != null) {{
currentInfoWindow.close();
}}
infoWindow.open(marker.get('map'), marker);
currentInfoWindow = infoWindow;
}});
}}
google.maps.event.addDomListener(window,'load',initialize);
var currentInfoWindow = null;",
coordinates[0], coordinates[1], DrawMarkers(groups));
ClientScript.RegisterStartupScript(this.GetType(), "mapInit", script, true);
如果 aspx 包含 div 和表单元素,就像现在一样,一切正常。但是我必须使用这个 aspx 文件的母版页。当我相应地更改其内容时,我必须删除表单元素,因为主文件中已经有一个。但是当我删除表单元素时,地图就消失了。
【问题讨论】:
标签: asp.net forms google-maps google-maps-api-3