How to create and install imagemaps at NC State


Contents:


These instructions for creating the map file are specifically for the MapEdit program.
The instructions for installing the imagemap are specific to NC State.

Description of imagemaps

Imagemaps are images that give users the freedom to click on different parts of an image to move to different WWW pages. At their most basic, imagemaps are just a fancy way to list URLs. Just about every type of World-Wide Web server supports imagemaps.

Imagemaps shouldn't be confused with just turning an image into a link. Imagemaps can have many "buttons" defined in them while simple image links can only have one.

Uses of imagemaps:

Anything that involves interacting with a graphic can make use of imagemaps. For example, suppose someone created a clickable image of the NCSU Campus. Users could click on a building on the map and then be shown a picture and information about that building.

Another example would be a group photo as an imagemap. When a user clicked on a person's face, a page with information about that person would appear.

The parts you need to make imagemaps work

The graphic or image
The graphic must be in GIF format.

The map file
This is a text file where the "button" regions are defined as well as the URLs associated with those buttons.

An HTML file
This is just a plain HTML file in which you'll combine the image and the map.

A web server and imagemap program
These are already supplied by the NC State Computing Center. All you have to do is link everything up correctly.

Software you'll need

Software for making the graphic

Currently, you can only create imagemaps with GIF (Graphics Interchange Format) images. It doesn't matter what program you use to create the graphic, as long as you can save it as, or convert it to, the GIF format later. The filename of the graphic should end in ".gif", and it should not contain any spaces. Failure to do these two simple things may confuse some browsers.

Software for making the mapfile

Once you've got the graphic you want to use, you have to define where all the "buttons" are. You create buttons by defining circles, rectangles and polygons within the GIF image. For each shape you define, you designate a URL which will be accessed if someone clicks within that shape.

There are several programs for making mapfiles, here are two popular programs:

For the Windows and Unix platforms, Mapedit is available from
http://www.boutell.com/mapedit/

Macintosh users have several imagemap editors to choose from as well, including WebMap available at http://www.city.net/ cnx/soft ware/webmap.html


How to make a new map file using Mapedit

Follow these steps:

  1. Get the GIF graphic

    PC Users: Download the graphic with Rapid Filer

    Using the LAN WorkPlace program called "Rapid Filer," download the graphic file.

    • Find the LAN WorkPlace group, open it, and start "Rapid Filer."

    • Log in to the ftp server.
      Remote Host Name: ftp.ncsu.edu
      User Name: anonymous
      Password: your_email_address

    • Once the ftp site window appears, select "Change Directory" from the "File" pull-down menu. A small window will appear.

    • Type into the window the path which leads to the graphic file:
      /pub/unity/lockers/project/cc-education/adv_html/
      

    • Copy the file called "buttons.gif" to the C:\ directory on your local hard drive.

    • Quit the "Rapid Filer" program.

    Workstation Users: copy the graphic to your account

    Use the 'cp' command to copy the image from the HTML tutorial directory to the directory you're currently in.

    cp /afs/unity.ncsu.edu/project/www/ncsu/cc/edu/html_trng/advclass
    /buttons.gif .
    
    Note that you shouldn't include the line break.
    Also note the ' .' (space dot) at the end of the command.

  2. Start Mapedit

    PC Users

    Find the Mapedit icon inside the "ITTC applications" group and double-click on it to start the program.

    Workstation Users

    Add the locker with the Mapedit program by typing
    add www
    
    Start the Mapedit program by typing
    mapedit &
    
  3. Load the graphic into Mapedit

    Using the mouse, select the "File" menu and choose "Open/Create Map". A dialog box will appear into which you should type the name of your soon-to-be created map file and the GIF graphic you just downloaded or copied.

    For PC users, the graphic is in the C:\ directory.
    Workstation users should omit the drive letters (c:\).

    Map Filename:
            c:\myfirst.map
    
    GIF Filename: 
            c:\buttons.gif
    
    It's standard practice to end map filenames with ".map", but you don't have to.

    The only other detail PC users need to attend to is to make sure the "NCSA" button is selected. There are two programs which deal with imagemaps, and NCSU uses the NCSA program. NCSA stands for National Center for Supercomputing Applications.

    When you press OK, the program will complain that the map file doesn't exist, and ask you to confirm that you want to create it. Click on OK to confirm that you want to create the file and continue.

  4. Define three buttons

    You now have the image loaded and are ready to define button regions.

    PC Users:
    From the "Tools" menu, select "Rectangle". Position the mouse pointer in the upper-left of the graphic's square button. Press the left mouse button once and release. Move the mouse pointer to the lower-right of the square button. Press the right mouse button once.

    Workstation Users:
    Use the first and second mouse buttons (MB1 and MB2) to start and finish drawing the button regions.

    Note: If you're using a PC and your rectangle gets messy, you can press [ESC] to cancel what you've done and start over. If you're using a workstation, press the [cancel] button.

    Once you complete a region, a dialog box will appear into which you should type the full URL you want associated with the rectangle (no relative linking). If you don't know the URL, type something informative so you can remember where the link was supposed to go. You can edit the map file after it has been created, which allows you to go look up the URL and insert it. In this case, type in the URL of NCSU's homepage: http://www.ncsu.edu/

    Define the other two buttons by selecting the appropriate tool , outlining the button, and entering the URL.

    For the circular button, use http://www2.ncsu.edu/ncsu/cc/pub/tutorials/tutor_page.html
    The Circle tool draws from the center outward.

    To use the Polygon tool, click on each vertex of the polygon until you've reached the last vertex, where you should click the right or MB1 button to finish. Although you may not close the polygon's sides, the imagemap program will interpret the two end points as being connected.

    For the polygonal button, use a URL of your choice, your homepage perhaps(?)

  5. Define the default URL

    If someone with poor aim should happen to miss all the button regions, they can be shown a default page. Sometimes the default page is the page with the imagemap, but you can also define a page with textual links or a "Try again" page that urges the user to be a little more accurate.

    To define a default URL using Mapedit, select the "File" menu and choose "Edit Default URL". Enter the URL of the default file. In this case, enter "default.html" -- we'll create this file later.

    Note: You cannot use relative linking when creating map files. You must specify full URLs in the map file.

  6. Test your imagemap

    PC users should pulldown the "Tools" menu and select "Test/Edit".
    Workstation users should click on "Test".

    Click on your image using the left button. When you click in a button region a window with the associated URL will appear and the region will be highlighted. Test all three of your buttons.

    Note: If you click outside all regions, the default URL will not be shown while in "Test" mode, but any highlighted window will disappear.

  7. Save the map file

    From the "File" menu, select "Save" or "Save map". The map file will be saved to the name you gave it when you started creating the map file. If you entered an incorrect path or filename, Mapedit will complain. To save your map despite this oversight, select "Save As" from the "File" menu and enter the correct path and filename.

  8. Quit the Mapedit program


Create the home and default HTML files

Create the "default.html" file

This is the file which will be accessed if someone misses all the buttons. It's a simple HTML file with only a heading and one line of text.

     <html>
     <h2>You missed!</h2>
     <hr>
     Please go back and try again.
     </html>
Create the "home.html" file which links the image and the map

To link your image with the map file, create a "home.html" file.

Note: PC users will create files that end with .htm. These files will be renamed later.

What you're doing is creating a hypertext link to the image map that surrounds the image itself. For example, if your map file is "myfirst.map", and your image is "buttons.gif", the line to link the map and the image would look like:

<A HREF="http://www4.ncsu.edu/cgi-bin/imagemap/~rmnixon/www/myfirst.map">
<IMG SRC="buttons.gif" ISMAP>
</A>

When someone clicks on the image, the <A HREF> tag calls the imagemap program in the cgi-bin directory (http://www4.ncsu.edu/cgi-bin/imagemap). The rest of the statement sends the imagemap program the location of your particular map file and image.

The use of the ISMAP attribute in the <IMG> tag indicates that the graphic is an imagemap and, as a standard HTML tag, will work with any browser that supports imagemaps.


Upload and testing

Follow these steps to move all the files you've created into your account.

PC Users

Using the LAN WorkPlace program called "Rapid Filer," upload all four files into your account.

  • Find the LAN WorkPlace group, open it, and start "Rapid Filer."

  • Log in to the ftp server.
    Remote Host Name: ftp.ncsu.edu
    User Name: your_userID
    Password: your_password

  • Change into the directory in which you've already set system:anyuser rl access permissions.

  • Copy the following files from the local machine in front of you into your directory:
    1. buttons.gif
    2. myfirst.map
    3. default.htm
    4. home.htm

  • PC users will have to use Rapid Filer to rename all the .htm files so that they end with .html

  • Quit the "Rapid Filer" program.

Workstation Users

Copy these files into the directory in which you've set up system:anyuser rl access permissions:

  1. buttons.gif
  2. myfirst.map
  3. default.html
  4. home.html

  • Test your imagemap

    Load the URL of your home.html file. The URL for your page will be in the form of

    http://www4.ncsu.edu/~userID/path/file.html

    For example, http://www4.ncsu.edu/~rmnixon/www/home.html

    or, if you prefer the old way

    http://www4.ncsu.edu/unity/users/first_letter_of_userID/userID/path/file.html

    Once the page is loaded, click away. You've done it!


    How imagemaps work

    This is what happens when someone accesses a page with an imagemap:

    1. The browser loads the page and the graphic which contains an <ISMAP> tag, indicating to the browser and server that it's an imagemap.

    2. The user clicks somewhere on the image.

    3. The browser translates the click into X,Y coordinates where 0,0 represents the top-left corner of the image. For rectangular buttons, the mapfile contains the top, left and bottom, right coordinates. For circular buttons, the mapfile contains the center coordinates and one point on the circumference of the circle (thus indicating its radius). Polygonal shaped areas have the X,Y coordinates of each vertex.

    4. The browser attaches the coordinates of the click to the imagemap's URL, and sends the new URL to the web server.

    5. The web server sends the URL to the imagemap program.

    6. The imagemap program looks at the map file and determines which region was hit.

    7. The imagemap program now sends the URL associated with the region to the web server, which then sends it along to the browser.

    8. The browser loads the new URL for the user.


    Design considerations

    Keep image sizes smallish

    Even the most patient people can become frustrated with huge images and the time they take to load. A good rule is to keep images no wider than 500 pixels (the approximate "standard" width of most browser windows) and no taller than about 400 pixels. Larger images take too long to load, and may not be completely visible all at once to people with smaller monitors.

    GIF images have only 256 colors

    An 8 bit color format, GIF images have a maximum of 256 colors. Just so you know where 256 comes from: 2x2x2x2x2x2x2x2=256. If you're using more colors, you'll lose them when you convert your image to GIF format. If you have a choice when you're converting, use the "Adaptive palette" and not the "System palette". "Adaptive" uses the 256 most common colors in your image. "System" uses the computer's built-in color palette, which usually tries to cover all the colors -- some of which may not even be in your image.

    Test your image and your map

    Not only should you make sure all the buttons work (and the default URL if you defined one), you should check to see what your image looks like on different kinds of computers. Some computers' monitors have higher resolutions which will make you graphic look smaller. Some computers can only display 256 colors. If such a computer is already using 50 colors to display other things, your image doesn't get to use all 256 of its colors. This can have very interesting, if not at all pleasing, consequences for your image. You can't, of course, control what colors will be in use on someone else's computer, but you can make GIF images that use fewer than 256 colors.

    Don't (carelessly) overlap regions

    If two "buttons" overlap, which URL will the user be sent to? The imagemap program will use the first URL listed in the mapfile that matches the coordinates. This is actually useful if you want to place a smaller button inside a larger one. You'd define the smaller button first and then the larger button.

    Use good graphical cues

    If you want people to use (and enjoy) your imagemap, you must provide an interface that clearly shows users what their choices are. Keep in mind that if you don't label buttons with text, there will always be someone who just can't understand what you mean by your graphical representation of "click here for perfect happiness." There aren't really any "standard" symbols or icons for anything. Lastly, make sure people can tell your graphic is a map.


    Return to the Advanced HTML tutorial