Version 1 (December, 2002)
© Pedro Pereira Gonçalves (pedro@inovagis.org)

Original File imgsrc.htm
Abstract Javascript function to dynamically change a GIServer Web Map Server request.
Author Pedro Pereira Gonçalves (email)
Implemented Functions function UpdateURL (source)
Last Change
History 2001-11-23 : Linked to "Working with Styles..."
2001-11-20 : Request was without SRS
2001-10-18 : Inserted into GIServer Tutorial
2001-10-16 : File Created
Index Page GIServer tutorial
Important Links: GIServer : Working with Styles
W3.org HTML 4.01 Specification web page : home page and objects
OpenGIS : home page and Web Map Server specification 1.1.0 (pdf , rtf)


IMAGE Simple Using Styles
Whole Earth
Australia
Europe
Whole Earth
Australia
Europe


When making a WMS request is sometimes quite anoying that the entire web page is reloaded. It is possible to avoid this by using a simple javascript function that will use the image property SRC to dynamically change the image location. For that it is necessary to create a javascript function that receives the new input paremeters and constructs the new GETMap URL. In this example a function called UpdateURL was created with the following interface:

    function UpdateURL (x1, y1, x2, y2, styles)

The x1, y1, x2, and y2 parameters are the new BBOX location to the requested map, while the sytles is the new OGC style requested for the map created.

In this function it is first necessary to construct the newURL and then applied it to the image SRC tag. Please notice that for this last operation is advised that you name your IMG, something like this

    <img border=1 name="MAP" width="300" height="150" src=" ...

If not you can always use the image document array.

The source code for this function is :

function UpdateURL (x1, y1, x2, y2, styles)
{
var newUrl = "/GIServer/map.cgi?REQUEST=GETMAP&LAYERS=TERRA.BORDERS&";
newUrl += "BBOX=" + x1 + "," + y1 + "," + x2 + "," + y2;
newUrl += "&SRS=EPSG:4326&WIDTH=300&HEIGHT=150"
newUrl += "&FORMAT=GIF&STYLES="+ styles;
document.MAP.src = newUrl;
}


Regarding the STYLES parameter the GIServer will transform this style into GIServer parameters. This is done because in the TERRA.BORDERS alias is registered the style COUNTRIES with the following parameters:
    FIELD=NAME&STYLES=brush-style:solid;color-linkage:text
This tells the GIServer to use the database field named NAME and to paint the data with the palette number 16. More information about this in "Working with Styles"