|
|
![]()
An image map is one of the best ways to build interactivity into your Web page. With mapped graphics, you can reach various Web sites by clicking on different spots in an image. Also, an image map is widely used to create a visual display for navigating your site. To perform its magic, an image map needs to coordinate two sets of information:
There are two types of image maps: server-side and client-side. Since most graphical browsers support server-side image maps, they have become the de facto standard on the Web. Server-side image maps reply on a Web server to interpret each click and serve up the appropriate HTML file, making them a little slower than client-side image maps.
The MAP file is simply a text file that contains a set of coordinates and URLs. Here is the general format for the MAP text file:
method url coord1 coord2 ... coordn
coord are each coordinates, format x,y.
The method is one of the following:
default For the default Url. Coordinates:
nonecircle For a circle. Coordinates: center edgepoint
poly For a polygon of at most 100 vertices.
Each coordinate is a vertex.
rect For a rectangle. Coordinates: upper-left
lower-right Here is an example of the map file on my Web site:
default yuenlink.htm
rect asia.htm 17,22 68,78
rect computer.htm 162, 21 222, 79
rect educ.htm 235, 22 296, 79
rect edtech.htm 306, 22 376, 82
rect schools.htm 239, 163 295, 227
rect weather.htm 310, 163 374, 228
rect www.htm 389, 165 447, 228
rect astro.htm 88, 23 146, 79
Here is an example of HTML codes that I used on my page to link to the image map:
<a href="http://dragon.ep.usm.edu/cgi-bin/imagemap/~yuen/button.map"><IMG SRC="http://dragon.ep.usm.edu/~yuen/coolmap.gif" border=0 ISMAP ></a>
There are three important points here:
It is easy to create a client-side image map if you know how to build a server-side image map. Follow the steps to create a server-side image map and then modify the map file as well as the HTML codes on the Web document.
<map name="banner">
<area shape="rect" href="asia.htm" coords="17,22 68,78">
<area shape="rect" href="computer.htm" coords="162, 21 222,79">
<area shape="rect" href="educ.htm" coords="235, 22 296, 79">
<area shape="rect" href="edtech.htm" coords="306, 22 376, 82">
<area shape="rect" href="schools.htm" coords="239, 163 295, 227">
<area shape="rect" href="weather.htm" coords="310, 163 374, 228">
<area shape="rect" href="www.htm" coords="389, 165 447, 228">
<area shape="rect" href="astro.htm" coords="88, 23 146, 79">
<area shape="default" href="yuenlink.htm">
</map>
The Map tag denotes the beginning of the client-side image map's definition. The Name tag that follows gives the definition a name you'll use when referring to the map in the USEMAP tag.Put the map file between </title> and </head>, or between </head> and <body> , or between <body> and </body>.
<IMG SRC="http://dragon.ep.usm.edu/~yuen/coolmap.gif" USEMAP="#banner" border=0 ISMAP>
The USEMAP tag tells a client-side-aware browser to use the map definition whose name appears after the pound sign (#).
Creating a Client-Slide Image Map
Last updated:
August 15, 2006
![]() Copyright © 1994 - 2007 Dr. Steve Yuen. All rights reserved. |