Clickable Geographical Map Regions
(Page 1 of 4 )
When your site has web pages with geographical maps, sometimes it is nice to make the regions of the map clickable. Imagine that you have a political map of Western Europe. It would be nice to make the countries clickable, so that when a user clicks a country, he would go to a page that has political information (e.g. history) about the country. We can use HTML image-maps to achieve this, but the shapes of countries are irregular. How can we turn an irregular shape into a clickable region? Keep reading.
Let me first briefly explain what an HTML image-map is.
HTML Image-Map
An image-map is an image with clickable regions. Three HTML elements are used to create image maps. They are the IMG element, the MAP element, and the AREA element. Consider the following hypothetical example:
<img src ="image.gif" usemap ="#ID" />
<map id ="ID">
<area shape = "rect" coords ="0,0,82,126" href ="details.htm" alt="Click for details" />
<area shape ="circle" coords ="90,58,3" href ="details.htm" alt="Click for details" />
<area shape = "poly" coords ="21,317,19,323,21,329" href ="details.htm" alt="Click for details" />
</map>
First you have the IMG tag. In this tag there has to be a usemap attribute, which provides the connection between the IMG tag and the MAP tag. Its value is the ID of the MAP element preceded by the # symbol. Next you have the MAP element, which has a start and end tag. This element must have an ID whose value must be the same as the usemap value, but without the # symbol. The content of the MAP element is the AREA elements. Each area has a shape attribute and a coordinates attribute.
The shape describes the clickable regions and it can be a rectangle, circle, or a polygon. If it is a rectangle then the first two coordinates are the coordinates of the left-top corner of the rectangle and the last two coordinates are the coordinates of the right-bottom corner of the rectangle. If it is a circle, then the first two coordinates are the coordinates of the center of the circle and the last coordinate (value) is the radius of the circle. If it is a polygon then the coordinates are in consecutive pairs, and each pair represents the coordinates of a vertex of the polygon.
These coordinates are measured with reference to the left-top corner of the image and not the left-top corner of the web page. If you want a region to result in a new web page after clicking, then you need to give the AREA element an href attribute. You can also give the AREA element an ALT attribute so that when the user's mouse pointer hovers over it, a tool tip appears, indicating what the user will see after clicking.
Next: Relationship between Geographical Regions and Image-Maps >>
More HTML Articles
More By Chrysanthus Forcha