Multimedia WWW Series:
Image Maps: Client Side

What is an image map?

An image map is a graphic element which allows the user to click on certain "hot" areas which respond like normal hypertext links. They are created by supplying a picture, some hypertext links, and the coordinates of the clickable areas on the graphic. When the processing which determines what "hot" area is clicked on is done by the computer running the browser it is called a client side image map.

What you need to start:

By the end of this session you will know:


Samples


Left and right navigation arrows
2 Circular regions mapped to a gif file:
Peek at the HTML

Clickable text areas
4 Rectangular regions mapped to a gif file:
Peek at the HTML

Clickable button-like areas
3 Rectangular regions mapped to a jpeg file:
Peek at the HTML

How To

There are 3 items necessary to get a functional image map. They are:

  1. The image.
  2. A MAP declaration.
  3. An IMG SRC declaration which includes the USEMAP option.

The image

The image can be of any type that a browser can handle, usually a JPEG or GIF. The image can be of any reasonable size. Full page-sized images are fine, as well as button sized images. Keep in mind that you are creating a user interface.

The MAP declaration

The MAP tag is symmetric, for every <MAP> there is an associated </MAP>. The syntax for this command is:

<map  name="mapname">
<area shape="rect" coords="left,top,right,bottom" href="somepage.html"></area>
<area shape="circle" coords="centerx,centery,radius" href="anotherpage.html></area>
<area shape="polygon" coords="x,y,x2,y2,x3,y3,...,xn,yn" href="yetanotherpage.html</area>
<area shape="default"  href="default.html"></area>
</map>

Notice that within the <MAP> tags there are several <AREA> statements. These statements tell the browser exactly which areas are clickable. Each statement includes the SHAPE, the COORDS(coordinates), and an HREF. The number of coordinates necessary is determined by the shape.

The 3 shapes available and their necessary coordinates are:
ShapeCoordinatesDescription of Coordinates
Rectangle always 4 coordinatesleft,top,right,bottom
Circle3 coordinatescenter x, center y, and the radius. (Yes, the radius isn't strictly a coordinate)
Polygonat least 3 pairs of coordinatesthe polygon is defined by at least 3 vertices
Defaultnoneeverwhere not previously defined


The IMG SRC declaration

This is a normal IMG SRC tag with the added USEMAP identifier.

<img usemap="#mapname" src="myimagegif">

The mapname is the same name that was assigned in the <MAP> statement defined above. The SRC is the image that was selected.

Exercise

Creating your own html file, map the following image to these addresses:
ObjectAddress to Map To
Circlehttp://www.sp.uconn.edu/~mmlab/training/imagemaps/circle.html
Squarehttp://www.sp.uconn.edu/~mmlab/training/imagemaps/square.html
Trianglehttp://www.sp.uconn.edu/~mmlab/training/imagemaps/triangle.html
Defaulthttp://www.sp.uconn.edu/~mmlab/training/imagemaps/noshape.html


The image that needs to be mapped:
This is a 200 x 200 pixel image.

Remember, 3 parts are needed:an image, a MAP tag, and an IMG SRC tag.
Click here if you need help figuring coodinates
Keep in mind the origin of this coordinate system is in the upper left. See the graphic to the right.
Click here to see the working map.
Click here to see the working sample code.

The Multimedia Lab provides a variety of software for your use. Animation, rendering, and media capture are all available. Stop by the lab for details!

webmaster@virtual.class.uconn.edu
10/2/96