[an error occurred while processing this directive]

The Map File

This page is part of the WebCom Web Publishing Guide. It provides a simple explanation how a "map" file is used to help create an imagemap, how to construct your map file (using publicly available tools or by hand), and what the individual components within the map file are.

Overview

A map file is a plain text file containing a list of URLs associated with areas on an image. A hotlink pointing to it is placed around the tag including the image in a page. When the image is clicked on, the server compares the location of the click to the list of URLs. If a match is found, the URL is returned to the browser, which then retrieves the file it points to.

This is the map file for the working example (this uses an NCSA format map file, users with existing map files in CERN format should see the CERN format documentation):

rect http://webcom.com/~webcom/imap/overview.html 8,5 81,34
rect http://webcom.com/~webcom/imap/news.html 86,7 139,34
rect http://webcom.com/~webcom/imap/products.html 145,6 215,35
rect http://webcom.com/~webcom/imap/contacts.html 221,8 291,37
rect http://webcom.com/~webcom/imap/other.html 299,6 437,35
default http://webcom.com/~webcom/imap/empty.html

default http://webcom.com/~webcom/imap/empty.html
This will be returned when the user clicks on an area not associated with a listed URL (such as empty space around objects). A good choice for a default URL is the current page itself. If no default URL is defined, an error message will be returned to the viewer when an area not associated with a listed URL is clicked on.
rect
This describes the shape of the area, so the server can figure out the format of the following points. Three types of shapes can be defined: circles, rectangles, and polygons (multi-sided shapes, such as those tracing outlines of an object within an image).
http://webcom.com/~webcom/imap/overview.html
This is the URL associated with (or "mapped" to) the area on the image defined by the points following.
8,5 81,34
This is a list of points defining the area on the image associated with ("mapped" to) the preceeding URL.

Note: The map file and the image itself are two separate objects, which combine to produce an effect. If you replace the image without altering the map file, the server has no way of knowing that anything has been changed, since all that is passed to it is a set of co-ordinates.

Utilities for creating map files

If you have X-Windows or Windows, we strongly recommend using the Mapedit program. Macintosh users can use WebMap to create their map files. People without access to these platforms must edit images by hand. The sample "map" file shown above was created using Mapedit.

Editing map files by hand

Unfortunately, if you don't have X-Windows, Windows or a Macintosh, you're stuck editing the file by hand.

The recommended method is to locate an image viewer which will tell you what point the cursor is currently sitting on, and then flip back and forth between a text editor and the image viewer. You will need to trace out the area on the graphic image with the cursor, and then copy the points outlining it into the map file.

[an error occurred while processing this directive]