next up previous contents
Next: CERN HTTPD's Htimage Up: Imagemap Configuration Previous: Imagemaps using MacHTTP

NCSA HTTPD's Imagemap Command

NCSA's HTTPD has a special directory called cgi-bingif in which you can put commands you want to be accessible by the server. One of the pre-supplied commands is imagemap, which is a much more sophisticated active map facility.

If we had the following lines of HTML in a document

<a href=/cgi-bin/imagemap/uk_map>
<img src=uk_map.gif ISMAP>
</a>

then when the user clicked on at (say) point (404,451), the client would submit a GET request to the server:

GET /cgi-bin/imagemap/uk_map?404,451

This calls the imagemap script in cgi-bin with two pieces of information - the QUERY_STRING environment variable with a value of ``404,451'' and the PATH_TRANSLATED environment variable with a value such as
`` /www/htdocs/uk_map'' (where `` /www/htdocs'' is the root of the server's document tree).

HTTPD has a configuration directory called `` conf''gif which contains all the server configuration files. Imagemap looks in this directory for a file called imagemap.conf.

In our particular case (we have a few image maps set up), this configuration file looks like:

lon_map:/www/conf/london.map
uk_map:/www/conf/uk.map
Worldmap:/www/htdocs/BBC/wrldserv/maps/World_map_image.map
Samerica:/www/htdocs/BBC/wrldserv/maps/Samerica.map
Africa:/www/htdocs/BBC/wrldserv/maps/Africa.map
Central_Asia:/www/htdocs/BBC/wrldserv/maps/Central_Asia.map
Asia:/www/htdocs//BBC/wrldserv/maps/Asia.map
Middle_East:/www/htdocs/BBC/wrldserv/maps/Middle_East.map
Europe:/www/htdocs/BBC/wrldserv/maps/Europe.map

Imagemap reads this file, and looks for `` uk_map'', which it finds associated with the file `` /www/conf/uk.map''. It then reads from `` /www/conf/uk.map'', of which the first few entries look like:

default http://www.cs.ucl.ac.uk/misc/uk/intro.html#map
#London
circle http://www.cs.ucl.ac.uk/misc/uk/london.html 416 451 396 458
#Canterbury
circle http://www.cs.ucl.ac.uk/misc/uk/canterbury.html 442 463 428 459
#Cambridge
circle http://www.cs.ucl.ac.uk/misc/uk/cambridge.html 413 405 400 407
#Bradford
circle http://www.cs.ucl.ac.uk/misc/uk/bradford.html 337 312 341 311
rect http://www.cs.ucl.ac.uk/misc/uk/bradford.html 335 317 372 325
#Birmingham
rect http://www.cs.ucl.ac.uk/misc/uk/birmingham.html 335 387 394 397

Each of these lines describes an active area of the map and the URL associated with that area (lines beginning with a `` #'' are comments).

The first entry on a line describes the shape of the active area. The second entry is the URL to redirect the client to if the user clicks within this area. The last arguments give the coordinates of the shape. The meaning of the coordinates is as follows:

default URL

This gives the URL to go to if the user clicked outside all of the specified shapes.
rect URL x1 y1 x2 y2

This specifies a rectangle with upper left corner (x1,y1) and lower right corner (x2,y2).
circle URL x1 y1 x2 y2

This specifies a circular hot spot with centre (x1,y1) and a point of the edge of the circle (x2,y2).
poly URL x1 y1 x2 y2 ... xn yn

This specifies a hot polygon with vertices (x1,y1) ... (xn,yn). The polygon is automatically closed is the first and last vertices are not the same.

Imagemap will run through the file and redirect the client to the URL of the item that best matches (with the exception of ``default'', which only matches if nothing else does).



next up previous contents
Next: CERN HTTPD's Htimage Up: Imagemap Configuration Previous: Imagemaps using MacHTTP



Jon Crowcroft
Wed May 10 11:46:29 BST 1995