我正在使用图书馆 subgurim 来处理谷歌地图。部分PostBack发生时如何保持GMap1
AJAX内部的高度和宽度?UpdatePanel
默认.aspx:
<div id="mainContent" style="width: 100%; height: 90%;">
<div id="content" style="width: 75%; border-left-style: groove; border-width: 1px;
overflow: auto; float: left;">
<asp:UpdatePanel ID="updtepnl_map" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Timer runat="server" ID="timer1" OnTick="upt_Tick" Enabled="False">
</asp:Timer>
<cc1:GMap ID="GMap1" runat="server" Key="AIzaSyDPnaewjFYzDu1acq_NorccJ_VNx_nOgio"
Height="100%" Width="100%" Version="3" Language="es" enableServerEvents="true" enableRotation="true"
OnClick="GMap1_Click" OnMapLoad="GMap1_MapLoad" OnMoveEnd="GMap1_MoveEnd" OnDragEnd="GMap1_DragEnd" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Bttn_Search" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="Bttn_startRefresh" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="timer1" EventName="Tick" />
<asp:AsyncPostBackTrigger ControlID="Center_Map" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="CkBxList_ADFSA" />
<asp:AsyncPostBackTrigger ControlID="CkBx_ADFSA" />
<asp:AsyncPostBackTrigger ControlID="CkBx_FEMSA" />
<asp:AsyncPostBackTrigger ControlID="CkBxList_FEMSA" />
<asp:AsyncPostBackTrigger ControlID="ImgBttn_SearchByS" />
<asp:AsyncPostBackTrigger ControlID="ImgBttn_SearchByIP" />
</Triggers>
</asp:UpdatePanel>
</div>
<div id="menu" style="width: 25%; border-style:hidden; border-width: 1px; overflow: auto;">
</div>
<div id="footer">
ADFSA © 2015
</div>
</div>
这是我的javascript 代码GMap1
,您可以在其中为inwindow.onload
和分配宽度和高度window.resize
:
var w = window, d = document, e = d.documentElement,
g = d.getElementsByTagName('body'),
x = w.innerWidth || w.clientWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight || e.clientHeight || g.clientHeight;
window.onresize = function () {
var obj3 = document.getElementById('divTop');
var obj1 = document.getElementById('general'),
footer = document.getElementById('footer'),
gmap1 = document.getElementById('GMap1'),
content= document.getElementById('content');
y = w.innerHeight || e.clientHeight || g.clientHeight;
window.content.style.height = y - (obj3.clientHeight + footer.clientHeight) + 'px';
window.menu.style.height = y - (obj3.clientHeight + footer.clientHeight) + 'px';
window.GMap1.style.height = content.clientHeight - 20 + 'px';
window.GMap1.style.width = content.clientWidth - 20 + 'px';
window.GMap1.style.margin = 10 + 'px';
}
window.onload = function () {
var obj3 = document.getElementById('divTop');
var obj1 = document.getElementById('general'),
footer = document.getElementById('footer'),
gmap1 = document.getElementById('GMap1'),
content= document.getElementById('content');
y = w.innerHeight || e.clientHeight || g.clientHeight;
window.content.style.height = y - (obj3.clientHeight + footer.clientHeight) + 'px';
window.menu.style.height = y - (obj3.clientHeight + footer.clientHeight) + 'px';
window.GMap1.style.height = content.clientHeight - 20 + 'px';
window.GMap1.style.width = content.clientWidth - 20 + 'px';
window.GMap1.style.margin = 10 + 'px';
}