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 / 19
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

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

- Does HTML5 Need a Main Element?
- Revisiting the HTML5 vs. Native Debate
- HTML5: Not for Phone Apps?
- HTML5 or Native?
- Job Hunting? Freelancer.com Lists This Quart...
- HTML5 in the News
- Report: HTML5 Mobile Performance Lags
- The Top HTML5 Audio Players
- Top HTML5 Video Tutorials
- HTML5: Reasons to Learn and Use It
- More of the Top Tutorials for HTML5 Forms
- MobileAppWizard Releases HTML5 App Builder
- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




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