Image Maps

Eternal gratitude to Kevin Hughes, <kevinh@pulua.hcc.hawaii.edu>, for his code to find intersections of points with circles and polygons, and to Casey Barton <cbarton@clark.dgim.doc.ca> who did the port of the NCSA imagemap program to DOS. I have since converted it to run as a native Windows application (trivial) using the new experimental Windows CGI interface.


Introduction

The imagemap program reads the coordinates sent by Mosaic when the user clicks on an ISMAP image, and returns a URL reference for a document that depends on the click location. The Windows version operates a bit differently than the Unix version. Casey decided to make the change in the interface so that it would be easy to launch imagemap directly. Since it is a native Windows application (and doesn't need a DOS VM) it runs quite fast.

The Central Configuration File

The imagemap script expects to find its configuration file as:

c:\httpd\conf\imagemap.cnf.

If you would like to change the location of this file, set up an environment variable called HTTPD_CONFDIR and set it to the path where imagemap.cnf willl be located.

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 WinScriptAlias /cgi-win/ c:/httpd/cgi-win/, named your map fish, and used the image fish33.gif for the map, the following line of HTML will reference it:

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


A Complete Example

The imagemap demonstration uses the following configuration files:

Central Configuration File

imapdemo : c:\httpd\conf\maps\imapdemo.map

Map Configuration File

The map configuration file for the demo is shown below. You can use Paintbrush or any other application that display the mouse coordinates by pixels to find locations.
# Demo map file
# This file should be pointed at by an entry in IMAGEMAP.CNF
#
# -Casey Barton

#The default page is loaded if no other entries are hit.
default /demo/noshape.html

# Circles are defined by two points; the first is the center, and the second
# is a point on the perimeter.
circle /demo/circle.html 50,50 50,10

# Rects are defined by two diagonally opposite vertices.
rect /demo/rect.html 130,10 170,90

# Polys can have any number of vertices. 
poly /demo/poly.html 250,10 210,90 290,90

Return to administration overview

Robert B. Denny <rdenny@netcom.com>