Map File Syntax

The example map page might also be helpful.

Your map file contains the information that relates the coordinates of a mouse click to a URL that you want to be returned when that area is clicked. The general syntax for lines in the map file is:

method URL coordinates

The method describes how you define your image hotspots. The following methods are available:

default - returns a default URL if the click was in an undefined area. No coordinates required.
circle - defines a circle. Coordinates required: center point and edge point.
rect - defines a rectangle. Coordinates required: upper left corner, lower right corner.
poly - defines a polygon. Coordinates required: all the vertices (up to 100).
point - allows you to define points such that a mouse click returns a URL according to which point it was closest to. If you use point There is no need to use default.

Overlapping Areas
Methods are evaluated based on the order in which they appear in the map file. Thus if you have overlapping areas, for example a circle within a rectangle, you would want to place the circle in the map file first, otherwise it would never get evaluated because the rectangle would cover it.

Comment Lines
Comments are allowed. Just start the lines with # (the pound sign).

Map Files are Text files
Be careful of strange characters such as carriage returns (^M).

URLs
URLs may be absolute or relative.

NCSA httpd map files are called    yourfilename.map


For NCSA httpd the specific syntax of a map file containing a circle, a rectangle, and a triangle would be:

default URL1
circle URL2 xc,yc xe,ye
rectangle URL3 x1,y1 x2,y2
polygon URL4 x1,y1 x2,y2 x3,y3


CERN servers use a script called htimage which uses a slightly different syntax for it's map files.

The methods available and the proper syntax are:

default URL
circle (x, y) r URL
rectangle (x1, y1) (x2, y2) URL
polygon (x1, y1) (x2, y2) ... (xn, yn) URL

The circle method uses the center point of the circle and the radius.


Client-side imagemaps have a related but different syntax.

Back to the example page

Chris Seidel