jmootips and Image Maps

jmootipsIn HTML and XHTML, an image map is a list of coordinates relating to a specific image, created in order to hyperlink areas of the image to different destinations (as opposed to a normal image link, in which the entire area of the image links to a single destination). For example, a map of the world may have each country hyperlinked to further information about that country. The intention of an image map is to provide an easy way of linking various parts of an image without dividing the image into separate image files.

In HTML an image map is made of the actual image, that is embedded with the <img>-tag. The image has to be assigned the attribute "usemap".
The image map comprise a <map>-tag and in the detail of the <area>-tags, which defines the fields with optional weblinks. These are similar to the <a>-Tag defining which URL should be opened.

A Sample of Image Map below:

<img src="/images/stories/lakes.jpg" alt="" width="450" height="339" border="0" usemap="#Map" />
<map name="Map" id="Map">
 <area shape="rect" coords="120,85,156,118" nohref alt="Lake Superior" />
 <area shape="rect" coords="142,206,179,237" href="##" alt="Lake Michigan" />
...
</map>

Image Map with Tooltips

With jmootips Version 1.1.1 you may add tooltips within images using image maps. (Note: This feature is not available if Bootstrap Javascript Framework used for jmootips. Also it may happen, that Microsoft's Internet Explorer does not display tooltips at all. For a solution for Bootstrap and Internet Explorer see next chapter of this article).
To add tooltips to be used with image maps, embed <area>-tags with tooltip tags:
{tip id="127" position="above"}<area shape="rect" coords="120,85,156,118" href="##" />{/tip}
jmootips will use the shape-attribute and coords-attribute to position tooltips within image.

Sample of Image Map with Tooltips

To show tip, move mouse pointer onto question marks within image:

Lake Huron Lake Erie Lake Ontario

Image Map with HTML/CSS Settings

Image Map defined with HTML/CSS Settings

The Bootstrap Javascript Framework with its tooltip plugins does not position tooltips correctly if an image map with <area>-tags is used. There is a solution to solve this problem by "translating" HTML <img>-tag and <area>-tags to HTML- and CSS-settings.
This way to provide tooltips within an image works as well with the Mootools Javascript Framework. Below three steps describe (using a sample image) how to implement this solution:
  1. Redefine your <img>-tag to a <div>element:
    <img src="/images/stories/lakes.jpg" alt="" width="450" height="339" border="0" usemap="#Map" />
    
    translates to:
    <div style="position:relative;width:450px;height:339px;background-image:url(/images/stories/lakes.jpg);">
    
  2. Redefine <area>-tags:
    <area shape="rect" coords="120,85,156,118" href="#" alt="Lake Superior" />
    
    translates to:
    <a href="#" style="opacity:0;position:absolute;top:85px;left:120px;width:20px;height:15px"></a>
    
  3. with embedded tooltip tags your new "image map" would look like:
    <div style="position:relative;width:450px;height:339px;background-image: url(/images/stories/lakes.jpg);">
    {tip id="127"}<a  nohref
            style="opacity:0;position:absolute;top:85px;left:120px;width:20px;height:15px"></a>{/tip}
    {tip id="128"}<a  href="##"
            style="opacity:0;position:absolute;top:206px;left:142px;width:20px;height:15px"></a>{/tip}
    {tip id="129"}<a  href="##"
            style="opacity:0;position:absolute;top:175px;left:236px;width:20px;height:15px"></a>{/tip}
    {tip id="130"}<a  href="##"
            style="opacity:0;position:absolute;top:260px;left:269px;width:20px;height:15px"></a>{/tip}
    {tip id="131"}<a  href="##"
            style="opacity:0;position:absolute;top:208px;left:350px;width:20px;height:15px"></a>{/tip}
    </div>
    
    
Image with tooltips (result of above settings):

Notes: Tooltip contents have been provided via Joomla articles - they are referred to using jmootips parameter "id". Both above solutions require use of jmootips version 1.1.1 or higher.