10.07.2017 Views

246996016-HTML5-Step-by-Step

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

174 Chapter 10<br />

Creating an Image Map<br />

You have seen how to make an image function as a hyperlink, but sometimes you might<br />

want different areas of the image to hyperlink to different locations. For example, suppose<br />

you have a map of the United States, and you want the user to be able to click<br />

individual states to view a page containing information specific to her location. To create<br />

such an effect, you must use an image map.<br />

An image map is an overlay for a graphic that assigns hyperlinks to specifically defined<br />

areas (hotspots) on the image. The hotspots can be rectangular, circular, or irregularly<br />

shaped (called a poly hotspot).<br />

The position of a rectangular hotspot is defined <strong>by</strong> two points: its upper-left and lowerright<br />

corners. Each point is expressed as a pair of numbers that represent the horizontal<br />

and vertical distance (in pixels) from the upper-left corner of the image. For example, in<br />

the following image, the shed door is defined as a hotspot. The upper-left corner of the<br />

shed door is located at 284,170—in other words, 284 pixels to the right and 170 pixels<br />

down from the upper-left corner of the image. The lower-right corner of the shed door is<br />

at 352,314. Therefore, the code for defining this particular hotspot is as follows:<br />

<br />

Top eft corner of<br />

the mage 0,0<br />

Top eft corner of<br />

hot spot 284,170<br />

Mouse po nter<br />

changes when<br />

over a hot spot<br />

ot spot area<br />

( nv s b e)<br />

Bottom r ght corner of<br />

hot spot 352,314

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!