Listing 7. Creating the HTML for the client side image map and the sidebar
my ($w,$h) = (CROP_WIDTH, CROP_HEIGHT);
# We use $x and $y to generate the image reference for crop.cgi:
#
my ($x, $y) = getImageMapCoords();
print << IMG_HTML;
<img src="crop.cgi?$x,$y" width="$w" height="$h"
usemap="#projects" alt="This area includes the following projects...">
<map name="projects">
IMG_HTML
my ($x_left, $y_top, $x_right, $y_bottom) = getZoomedInCoords( $x, $y );
my @Locations = getIconLocationsByCoords($x_left, $y_top, $x_right, $y_bottom);
# Create an entry in the client side image map for each project
# location
#
foreach my $iconloc ( @Locations ) {
my ( $left, $top, $right, $bottom, $mapcode, $name ) =
(
$iconloc->{X} - $x_left - HALF_ICON,
$iconloc->{Y} - $y_top - HALF_ICON,
$iconloc->{X} - $x_left + HALF_ICON - 1,
$iconloc->{Y} - $y_top + HALF_ICON - 1,
encode_entities( $iconloc ->{Code} ),
encode_entities( $iconloc ->{Name} )
);
print << AREA_HTML;
<area coords="$left,$top,$right,$bottom" alt="$name"
href="viewProjects.cgi?Code="$code">
AREA_HTML
}
print "</map>";