I have a Google Map on which I display markers by fetching the latlng's from a database on a Button Click. To avoid postback I put this button in an update panel.
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
style="z-index: 1; left: 778px; top: 270px; position: absolute; height: 25px" Text="Button" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
Button_Click:
protected void Button1_Click(object sender, EventArgs e)
{
ScriptManager.RegisterClientScriptBlock(this, typeof(Button), "currentloc", "showcurrent()", true);
}
Javascript in aspx:
function showcurrent()
{
var rec_loc= document.getElementById('<%=currentloc.ClientID %>').value;
var splitloc=[];
splitloc= rec_loc.split(',');
var clat=parseFloat(splitloc[0]);
var clng=parseFloat(splitloc[1]);
var cpos= new google.maps.LatLng(clat,clng);
var cmarker= new google.maps.Marker({icon:'http://www.googlemapsmarkers.com/v1/A/0099FF/', position:cpos,map:map});
map.setCenter(cmarker.getPosition());
}
In body onload I initialize and load the map and its fine. But when I click the button, I end up with a blue screen in the map(the map controls like zoom, etc are still there though). Where am I doing wrong? Please help.