In 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 (The coordinates of the respective areas can be found out, for example, with the graphics tools from Gimp):
<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>
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:
Note: If bootstrap javascript framwork used, then tooltips are not positioned correctly.
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:
-
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);">
-
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>
-
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>
Notes:
To show tip, move mouse pointer onto question marks within image:
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.