Alachua Freenet
Imagemap Tutorial

This document is a step-by-step tutorial for designing and serving graphical maps of information resources with the imagemap CGI program. Through such a map, users can be provided with a graphical overview of any set of information resources; by clicking on different parts of the overview image, they can transparently access any of the information resources (possibly spread out all across the Internet).

This document was derived from the NCSA imagemap tutorial.


What you need

This tutorial also assumes use of WWW browser that supports inlined GIF images and HTTP/1.0 URL redirection. Netscape and Mosaic 2.x are such browsers.


Your First Image Map

In this section we walk through the steps needed to get an initial image map up and running.

  • First, create an image.

    There are various tools you can use to create your image. The important thing is that the image ends up in GIF format.

    Many Imagemapping resources are available in the WWW FAQ How do I set up a clickable image map?

    In addition, for Unix, there is a program called xpaint (you can find it on ftp.x.org in /R5contrib; here's the tar file).

  • Second, create an Imagemap Configuration file.

    This file maps regions to URLs for the given image.

    A common scheme for an imagemap is a collection of points, polygons, rectangles and circles, each containing a short text description of some piece of information or some information server; interconnections are conveyed through lines or arcs. Try to keep the individual items in the map spaced out far enough so a user will clearly know what he or she is clicking on.

    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: Notes:

    Here is an example image map linked from Mosaic Demo page.

    Here is what an imagemap configuration file looks like:
         default /X11/mosaic/public/none.html
    
         rect http://cui_www.unige.ch/w3catalog    15,8    135,39
         rect gopher://rs5.loc.gov/11/global       245,86  504,143  
         rect http://nearnet.gnn.com/GNN-ORA.html  117,122 175,158 
    
    The format is fairly straightforward. The first line specifies the default response (the file to be returned if the region of the image in which the user clicks doesn't correspond to anything).

    Subsequent lines specify rectangles in the image that correspond to arbitrary URLs -- for the first of these lines, the rectangle specified by 15,8 (x,y of the upper-left corner, in pixels) and 135,39 (lower-right corner) corresponds to URL http://cui_www.unige.ch/w3catalog.

    So, what you need to do is find the upper-left and lower-right corners of a rectangle for each information resource in your image map. There is a program for Unix called mapedit that you could use to help build the map file. Another Unix tool for this is xv (also on ftp.x.org in /contrib) -- pop up the Info window and draw rectangles over the image with the middle mouse button.

    It doesn't matter where you put your map configuration file or what you name it. For the purposes of this example, let's assume it's called /foo/sample.map.

    Third, referencing your imagemap in your HTML file.

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

    For example, if you have created a example.map file in the directory called path in your public_html home directory, and used the image sample.gif for the map, the following line of HTML will reference it:

         <A HREF="http://foo.edu/cgi-bin/imagemap/~username/path/example.map">
         <IMG SRC="sample.gif" ISMAP>
         </A>
    
    Fourth, try it out!

    Load the HTML file, look at the inlined image, click somewhere, and see what happens.


    A Complete Example

    Here is the example imagemap HTML. Use your browser's "View Source" mode to inspect the HTML.

    Map Configuration File

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

    Reference the map in HTML document:

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


    Real-World Examples

    Following are examples of distributed image maps on servers in the real world; they may or may not work at any point in time.


    AFN WebMaster