Google Map API with UpdatePanel

Last post 12-01-2008 12:47 AM by Vince Xu - MSFT. 4 replies.

Sort Posts:

  • Google Map API with UpdatePanel

    11-27-2008, 8:17 AM
    • Member
      47 point Member
    • MAlex001
    • Member since 09-14-2005, 5:49 PM
    • Posts 79

    hi, I have a google map in my web site that it have to be updated every 5 minutes. I have added  a Timer control in the page and an Updade panel to achieve that

    The first time the page is display the map is populate with some marker in a javascript  function.

    How can I call this function (javascript function )  from server side when the Tick event of the Timer is fired.?

    Code: 

    type="text/javascript">

     

    function load() {    HERE I POPULATE THE MAP WITH ALL INFORMATION I NEED TO SHOW .........} </script >

     

    <body onload="load()" onunload="GUnload()" >

     

    <form id="form1" runat="server" >

    <asp:ScriptManager ID="ScriptManager" runat="server" > </asp:ScriptManager>

    <asp:UpdatePanel ID="updatePanel1" runat="server" EnableViewState="true" UpdateMode="Always" >

    <Triggers><asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /></Triggers>

    <ContentTemplate><div id="map" style="width: 1000px; height: 500px" > </div></ContentTemplate>

    </asp:UpdatePanel>

    <asp:Timer Interval="15000" ID="Timer1" runat="server" OnTick="Timer1_Tick" ></asp:Timer>

  • Re: Google Map API with UpdatePanel

    11-27-2008, 11:34 AM
    Answer
    • Star
      13,643 point Star
    • gt1329a
    • Member since 06-24-2002, 12:53 AM
    • Atlanta
    • Posts 2,252
    • ASPInsiders
      TrustedFriends-MVPs

    You shouldn't go to the server for that.

    Create a javascript function called pageLoad().  This will be executed automatically when the page loads (assuming you have a ScriptManager on the page).  In that function you can use setInterval to refresh your map on a timer:

    function pageLoad() {
      // 30000 is 5 minutes converted to ms.
      setInterval(load, 30000);
    }
      
    Encosia - ASP.NET, jQuery, AJAX, and more.

    Latest article: Emulate ASP.NET validation groups with jQuery validation
  • Re: Google Map API with UpdatePanel

    11-27-2008, 10:23 PM

    You can call javascript using RegisterStartupScript Method of ScriptManager

    string strMessage = "My Test Message";

    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "alertmsg", "alert('" + strMessage + "');", true);

    http://forums.asp.net/t/1343558.aspx

    http://forums.asp.net/t/1352993.aspx

    Chetan Sarode
    Software Engineer,
    Approva Systems Pvt Ltd,
    Pune, India.
  • Re: Google Map API with UpdatePanel

    11-27-2008, 10:32 PM
    • Member
      47 point Member
    • MAlex001
    • Member since 09-14-2005, 5:49 PM
    • Posts 79

    Thank you very much for your help.

    In the same way I can set up an interval, can I stop the timer when some event happen (like showing a modal pop up window) and set up again when the modal popup window is close?

     

  • Re: Google Map API with UpdatePanel

    12-01-2008, 12:47 AM
    Answer

    Hi,

    If you set the Timer with Interval, in ModalPopup client hidden event, you can clear the Timer.

    Set Interval timer:

    var timer= setInterval(function, 30000);

    Clear Interval timer:

    clearInterval(timer);

    var timer=null;
    function pageLoad()
    {
        $find('ModalPopupBehaviorID').add_hidden(onhidden);
    }
    function onhidden()
    {
        clearInterval(timer);
    }

     

    Vince Xu
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 1 (5 items)