Retrieving Variables
The previous page showed how MapServer's behavior can be influenced by
sending CGI variables to it. This page shows how the results can be processed
in
.
When finished, MapServer sends back
its results via the template file. To see how this works,
we'll have a closer look at the template file
.
I didn't say so before, but it is this file that is put in the window
when a MapServer request returns to the browser. Mapserver replaces everything
between square brackets with its computed results. A description of
every variable that can be put in square brackets is in the
.
The most important template variable is undoubtedly [img]. It is
replaced by the URL of the map image produced by MapServer. In the
template file I put it at the physical top of the page:
<img src=[img] style="position:absolute;top:0;left:0">
When using MapClient, allmost all other return variables are put in
hidden variables within a form. In this examples I used three of them,
to get the actual extent, size and scale of the returned map. The form
in the template file looks like this:
<form>
<input type=hidden name=mapext value="[mapext]">
<input type=hidden name=scale value="[scale]">
<input type=hidden name=mapsize value="[mapsize]">
</form>
Every variable has a name and a value. The values are between brackets, so
MapServer replaces them by the computed values.
The win method "getReturnedVar()" gets the value of a named hidden variable
in the first form within the window. In the
HTML file, the function getVars() uses this method to get the
values from the hidden variables; it puts these
into the three textboxes via their JavaScript/DOM variables.
Note that the values change when the window is resized.