I have a map of the UK broken down into various geographic regions. I would like to make it so that when a user hovers over the section some text appears.
My question is, what is the best way to get the images to do this.
One way I have tried is to create a png file for each area in the correct location within a fixed sized canvas with a totally transparent backgroud. This works in terms of showing all the areas as one complete map. But does not allow me to add a handle onto each image section as they are stacked on top of each other so only the top one is available.
I have also attempted to put an 'area' over the top to try and define a hot spot. However this also didn't work as the shapes are too complex...
Here is the html/css markup
<script type="text/javascript">
$(document).ready(function() {
$('#scot').hide();
$('#wales').hide();
$('#scotmap').click(function() {
$('#scot').show();
});
$('#img2').click(function() {
$('#wales').show();
});
});
</script>
<div id="wrapper">
<div id="img1" class="mappiece">
<img src="Images/map/scotland.png" alt="Scotland">
</div>
<div id="img2" class="mappiece">
<img src="Images/map/nw.png" alt="Scotland">
</div>
<div id="img3" class="mappiece">
<img src="Images/map/se.png" alt="Scotland">
</div>
<div id="img4" class="mappiece">
<img src="Images/map/wales.png" alt="Scotland">
</div>
<div id="img5" class="mappiece">
<img src="Images/map/ireland.png" alt="Scotland">
</div>
<div id="img6" class="mappiece">
<img src="Images/map/yarmouth.png" alt="Scotland">
</div>
<div id="img7" class="mappiece">
<img src="Images/map/york.png" alt="Scotland">
</div>
<div id="map" class="mappiece">
<area id="scotmap" shape="poly" coords="76,9,76,50,87,50,87,92,96,92,96,101,105,101,105,132,120,132,120,122,132,124,137,120,151,124,154,128,160,127,163,129,171,125,173,119,164,92,147,76,164,37,144,7" nohref alt="Scotland Map" />
</div>
</div>
<div id="text">
<div id="scot">
<p>Hello Scotland</p>
</div>
<div id="wales">
<p>Hello Wales</p>
</div>
</div>
body{background-color:#fff;}
#wrapper{
width:237px;
height:258px;
position: relative;
}
.mappiece {
position: absolute;
width:237px;
height:258px;
top:0;
left:0;
}
#img1 {
z-index:80;
}
#img2 {
z-index:20;
}
#img3 {
z-index:30;
}
#img4 {
z-index:40;
}
#img5 {
z-index:50;
}
#img6 {
z-index:60;
}
#img7 {
z-index:70;
}
Any points in the right direction will be greatly appreciated. In terms of the mouse over /mouseout/click jquery events, I am ok with these. It is just the image manipulation that I am struggling with.
Kind Regards