Ford & Mason Ltd
HOME
ABOUT
CONTACT
RESOURCES
ADVERTISING



donations support the development of
cronolog.org
and
refcards.com

next up previous contents index
Next: The mapedit program Up: Image maps Previous: Image maps


Creating image maps for use with CERN and NCSA servers

The image map programs distributed with the CERN and NCSA servers provide simple ways of creating image maps using map files in conjunction with in-line images. Because they differ slightly from each other in the organization and syntax of their map files, you need to know which program you are going to use before setting up a map file.

An image map consists of an in-line image and a map file that defines the correlation between regions of the image and URLs. The map file contains definitions of different shaped regions, such as rectangles, circles and polygons, that map to other documents. It is permissible for regions to overlap. The image map programs check the coordinates sent against each region in the map file in turn, to determine whether the point lies within that region and, if so, redirect the browser to the URL associated with the region. Hence, if a point lies within a number of overlapping regions, the first such region listed in the file will always be selected. The file can also contain a default URL that is used if the point does not lie within any of the regions listed. To set up an image map, you must:

  • Create or obtain a suitable image using any of the methods outlined in Section gif.

  • Create the map file. If you are using the NCSA program, you also need to enter the name of this file into a central configuration file (this requires the cooperation of the server administrator).

  • Set up a hypertext link from the HTML document to specify the image handling program and map file.

It is possible to construct an image map manually, calculating the location of each of the regions, as illustrated in Figure gif. Coordinates are measured in pixels relative to the top-left hand corner and are expressed as a pair of x and y values, measured across and down respectively. There are roughly 20-30 pixels per inch on a computer screen, depending on the type of screen. An interactive graphics program, such as XV on UNIX, can be used to determine the pixel coordinates of points on an image.

  
Figure: Defining regions on an image

The CERN and NCSA programs define rectangles and polygons in essentially the same way but differ in how circles are defined. Each line in the map file defines a separate region. The CERN htimage program lists the coordinates of the points defining the region before the URL, while the NCSA imagemap program lists the URL first.

Rectangular regions are defined by the coordinates of two opposite corners.

Polygons are defined by a list of points in the same way as a child's `join the dots' picture; the last point is assumed to be the same as the first point in order to complete the polygon. The NCSA program places a limit of 100 points on the definition of a polygon, while the CERN program has no limit.

  
Table: Image Map Program Syntax

With the CERN program a circle is defined by its centre point and radius, while the NCSA program uses the centre point and any point on the circumference.

Table gif shows the syntax of map file entries. The following example shows a CERN htimage image map file configured for the regions shown in Figure gif.

    rectangle (5,10) (45,30)            /examples/rectangle.html
    circle    (70,20) 14                /examples/default.html
    circle    (70,20) 10                /examples/annulus.html
    polygon   (85,30) (100,10) (115,30) /examples/triangle.html
    default                             /examples/default.html


next up previous contents index
Next: The mapedit program Up: Image maps Previous: Image maps

[ITCP]Spinning the Web by Andrew Ford
© 1995 International Thomson Publishing
© 2002 Andrew Ford and Ford & Mason Ltd
Note: this HTML document was generated in December 1994 directly from the LaTeX source files using LaTeX2HTML. It was formatted into our standard page layout using the Template Toolkit. The document is mainly of historical interest as obviously many of the sites mentioned have long since disappeared.

 
Copyright © 1996-2002 Ford & Mason Ltd