The Improved imagemap Script

Eternal gratitude to Kevin Hughes, kevinh@pulua.hcc.hawaii.edu, for his code to find intersections of points with circles and polygons.


Compile the imagemap script

If you downloaded the source, you need to compile the imagemap script. Do this by first cd'ing into your ServerRoot, and then cd into the cgi-src subdirectory. Then, type make imagemap and you should be all set.


The Central Configuration File

The imagemap script expects to find its configuration file as:

/usr/local/etc/httpd/conf/imagemap.conf.

If you would like to change the location of this file, edit cgi-src/imagemap.c, change the setting of CONF_FILE, and recompile with make imagemap.

In this file, lines beginning with a # are comments. Every other non-blank line consists of:

name : path

name is the name of the particular mapping. You use it when you reference the image.

path is the full path to the map configuration file for this mapping.


The Map Configuration File

This file maps regions to URLs for the given image.

Lines beginning with # are comments. Every other non-blank line consists of the following:

method url coord1 coord2 ... coordn

coord are each coordinates, format x,y. The number depends on method.

method is one of the following:

url is one of the following: Note: each method is evaluated in the order it is placed in the configuration file. If you have overlapping areas, such as a circle inside of a rectangle, you should place whichever one you want evaluated first before the other in the map file. In this case, we would put the circle before the rectangle.


Referencing Your New Map

To reference your new map, you construct URLs pointing to it.

For example, if you have a ScriptAlias /cgi-bin/ /usr/local/etc/httpd/cgi-bin/, named your map fish, and used the image fish33.gif for the map, the following line of HTML will reference it:

<A HREF="/cgi-bin/imagemap/fish"><IMG SRC="fish33.gif" ISMAP></A>


A Complete Example

The fish demo in another section of this manual used the following configuration files:

Central Configuration File

fish : /usr/local/etc/httpd/conf/fish.map

Map Configuration File

The map configuration file used for this picture was rather lengthy. I used xv to get the coordinates.


Return to administration overview

httpd@ncsa.uiuc.edu