HOW TO

Display "Please Wait" message on client during MOIMS processing

Last Published: April 25, 2020

Summary

It may be desirable to display a "Please Wait", or other message, in the client browser while processing takes place on the mapserver. You can accomplish this using two transactions. This document describes the conceptual steps involved.

Procedure



  1. Add <INPUT TYPE=hidden NAME=waitpage VALUE=waitpage> tag to primary HTML document.

    The primary HTML document contains the map and the <FORM> that will be submitted to the server. This <FORM> probably already contains hidden <INPUT> tags to store information about the map's extent, visible layers, or other information. In the MapObjects mapserver application, locate the code responsible for creating the primary HTML page. An example subset of this code is shown here:

    Code:
    .WriteString "<FORM NAME=MapForm TARGET=MapFrame ACTION=/scripts/esrimap.dll>" & vbCrLf
    .WriteString "<INPUT TYPE=hidden NAME=name VALUE=MyMapservice>" & vbCrLf
    ' add radios
    .WriteString "<INPUT TYPE=RADIO NAME=Cmd VALUE=ZoomIn " & _
    IIf(f_bZoomSelected, "CHECKED", "") & "> Zoom In" & vbCrLf

    Add code to include a new hidden <INPUT> tag in the <FORM> for the primary HTML page; this will allow the mapserver application to tell whether to return a "Please Wait" page, or process the request as usual.

    Code:
    .WriteString "<FORM NAME=MapForm TARGET=MapFrame ACTION=/scripts/esrimap.dll>" & vbCrLf
    .WriteString "<INPUT TYPE=hidden NAME=name VALUE=MyMapservice>" & vbCrLf
    .WriteString "<INPUT TYPE=hidden NAME=waitpage VALUE=waitpage>" & vbCrLf
    ' add radios
    .WriteString "<INPUT TYPE=RADIO NAME=Cmd VALUE=ZoomIn " & _
    IIf(f_bZoomSelected, "CHECKED", "") & "> Zoom In" & vbCrLf

  2. Modify the mapserver code to check incoming requests for the presence of the "waitpage" keyword.

    Find the Weblink's Request event. Follow the code's logic to find the point where all the information has been extracted from the argument/value arrays. Add code to look in one of these arrays for "waitpage", and if it is found, call a new subroutine that will send the "Please Wait" page back to the client.

    Code:
    ' Check to see if waitpage is to be sent
    Dim i As Integer
    For i = 0 To arguments.Count - 1
    If UCase$(arguments(i)) = "WAITPAGE" Then
    ' Call new sub to create "Please Wait" page on server.
    ' Pass all request information to the new subroutine:
    ' what action was requested by the client, the
    ' current map extent, where the user clicked, etc.
    DoWaitPage strCMD, oExt, lClickX, lClickY
    ' Set any global variables to Nothing here, to ensure mapserver is stateless
    Exit Sub
    End If
    Next i

  3. Add mapserver code to generate the "Please Wait" page.

    Create a new subroutine with the name specified in Step 2. This subroutine will use the Weblink's WriteString method to send an HTML page to the client, instructing the user to wait while the map request is processed.

    This HTML page will also contain two JavaScript functions. The purpose of these functions is to send the original request back to the mapserver; the only difference is that this second request will not have the extra hidden <INPUT> tag from Step 1 above. When this second request is received by the mapserver, it will be processed as usual.

    Code:
    Public Sub DoWaitPage(cmd As String, ext As MapObjects.Rectangle, x As Long, y As Long)

    With WebLink
    ' specify what type of data we are going to send to the browser
    .WriteResponseHeader "Content-type: text/html" + vbCrLf + vbCrLf
    .WriteString "<HTML><HEAD>" & vbCrLf
    '
    ' Write JavaScript functions into the header section of the HTML doc
    .WriteString "<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf
    .WriteString " function TimeOut() {" & vbCrLf
    .WriteString " timerID = setTimeout(""GetMap()"", 100);" & vbCrLf
    .WriteString " }" & vbCrLf
    .WriteString " function GetMap() {" & vbCrLf
    .WriteString " parent.MapFrame.location = 'http://<WEBSERVER>/scripts/esrimap.dll?" & _
    "name=MyMapServiceName&cmd=" & cmd & "&Top=" & ext.Top & "&Bottom=" & ext.Bottom & _
    "&Left=" & ext.Left & "&Right=" & ext.Right & "&click.x=" & x & "&click.y=" & y & "';" & vbCrLf
    .WriteString " }" & vbCrLf
    .WriteString "</SCRIPT>" & vbCrLf
    .WriteString "<TITLE>MOIMS PleaseWait MapService</TITLE> </HEAD>" & vbCrLf
    '
    ' Call the TimeOut function when the page is loaded
    .WriteString "<BODY onLoad=""TimeOut()"" BGCOLOR=#ffffff>" & vbCrLf
    '
    ' Add HTML code here to display the "Please Wait" message or graphic
    .WriteString "Please wait... :-)" & vbCrLf
    .WriteString "</BODY></HTML>" & vbCrLf
    End With
    End Sub


    Warning:
    Please note the code above is for illustration purposes only. Be aware that browsers have different ways of referring to documents; please consult the Document Object Model for the browser to determine the correct syntax. Also, some browsers may not support JavaScript functions.

Article ID:000002275

Software:
  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic