Home arrow HTML arrow Clickable Geographical Map Regions
HTML

Clickable Geographical Map Regions


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.

Author Info:
By: Chrysanthus Forcha
Rating: 5 stars5 stars5 stars5 stars5 stars / 3
June 03, 2008
TABLE OF CONTENTS:
  1. · Clickable Geographical Map Regions
  2. · Relationship between Geographical Regions and Image-Maps
  3. · Code Explained
  4. · Caution, Animation, Conclusion

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Clickable Geographical Map Regions
(Page 1 of 4 )

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.


blog comments powered by Disqus
HTML ARTICLES

- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5
- BBC Adopts HTML 5, Mozilla Addresses Issues
- Advanced Sticky Footers in HTML and CSS
- HTML and CSS Sticky Footers
- Strategy Analytics Predicts HTML5 Phones to ...
- HTML5 Guidelines for Web Developers
- Learning HTML5 Game Programming
- More Engaging CSS3 and HTML Background Effec...
- Engaging HTML and CSS3 Background Effects
- More Web Columns with CSS3 and HTML
- Columns with CSS3 and HTML
- Creating Inline-Block HTML Elements with CSS
- Drag and Drop in HTML5: Parsing Local Files

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials