How the imagemap mechanism works

1. The Click is sent to the server over the net
The user clicks on an area of a picture, and depending on where
they click a different URL is returned. This is very simple to the
user, but the underlying mechanism is rather complex. This document is
intended to explain the mechanism.
Referring to the diagram below, the user clicks on the image,
the browser (Currently Mosaic only), appends the co-ordinates of the
click to the URL associated with the map. It knows to do this by use
of the ISMAP argument in the IMG tag.
The URL is of the form:
http://server.net.address/cgi-bin/imagemap/Mapname
The cgi-bin element may be replaced with htbin on
older servers. The Mapname is a symbol that uniquely identifies
a particular map for a server. The co-ordinates are appended in the
format ?145+167
2. The server receives and decodes the request
When the server receives the request it deocdes the URL. The
cgi-bin or htbin part instructs the server to run a
program in a directory cgi-bin or htbin. The next part tells it the
program is imagemap, and the rest of the URL is given to imagemap as
arguments.
3. The Server starts the imagemap program
The program that does the work is called imagemap, and lives
in either the cg-bin or the htbin directory, under the
servers root directory ($SERVERROOT in the configuration files). This
program is started by the server, and returns it's output to the
server.
It is passed the rest of the URL, consisting of a unique
symbol for the map in question, and a pair of XY co-ordinates.
4. The imagemap program interprets the symbol
The imagemap server looks up the symbol a table held in the
file imagemap.conf. This has a list of symbols, and a list of
associated map files, the map file holds the information about what
parts of the image a linked to which URLs. If this file is missing
or garbled imagemap will fail, usually in a mysterious (to the user)
manner.
5. The imagemap program reads and interprets the relevant map
file
Imagemap loads the file specified as corresponding to the
unique symbol it was given. The file consists of a list of shapes and
sizes, eg. rectangle from 131,0 to 170,100. The imagemap program
figures out which of these shapes the co-ordinates of the users click
lie in. Corresponding to each shape is a URL.
6. The URL is passed back to the server by imagemap.
7. The server returns the URL to the client
The server replies with:
Location: URL_returned_by_imagemap
8. The Client interprets the Location: response
The client reacts to a Location: response by
immediately jumping to the URL mentioned. The URL is retrieved in a
separate transaction, and the user is returned the data relevant to
where they clicked.
Martin Hargreaves