PHP image creator/map

I’m having a slight problem with a PHP generated image.

The code:

if(!isset($_GET['map'])) { $_GET['map'] = 0; }
echo "<map name='mapdata' id='mapdata'>";
foreach($properties[$_GET['map']] AS $propname => $propdata) {
	echo '<area shape="poly" coords="'.$coords[$_GET['map']][$propname].'" href="moo.html">';
	echo "\
";
}
echo "</map><img name='map' src='getmap.php?map=".$_GET['map']."' usemap='mapdata' />";

The getmap page is correctly returning a properly formed PNG file, but the imagemap isnt being applied.

$properties is properly instantiated, as is $_GET[‘map’]. The <area> tags are properly output.

…is there something ridiculously easy i’m missing, or can imagemaps not be applied to php-generated images?

When you copy/paste the generated HTML source code, does it still fail to work? If so, can you please show us the appropriate part of the generated HTML source code.

Pasting the whole thing isnt really viable since there are nearly 500 entries (and hotspots)… I’m assuming you want me to make sure that if put into HTML form with a static .png that the hotspots work… they dont.

For sake of sanity i’ve made everything point to ‘moo.html’… the html output is:

<map name='mapdata' id='mapdata'><area shape="poly" coords="500,458,498,459,489,470,482,474,485,475,487,481,487,483,494,483,496,485,498,488,502,489,503,484,504,470,501,465" href="moo.html" />
<area shape="poly" coords="501,490,498,489,493,484,493,482,487,483,485,479,485,475,482,475,469,479,469,491" href="moo.html" />
<area shape="poly" coords="443,489,457,482,464,482,468,480,468,491,463,492,463,495,455,498,446,498" href="moo.html" />
<area shape="poly" coords="413,513,414,497,423,495,428,494,434,490,444,489,447,498,437,502,437,513" href="moo.html" />
<area shape="poly" coords="471,504,464,500,462,496,463,492,467,490,501,491,506,495,512,495,516,500,529,506,529,510,471,511" href="moo.html" />
<area shape="poly" coords="472,551,468,551,447,541,447,537,438,517,437,501,447,498,455,499,461,496,462,499,471,504" href="moo.html" />
<area shape="poly" coords="472,551,487,550,493,544,500,537,502,534,515,529,523,522,529,511,472,511" href="moo.html" />
...... (lots more areas here)
<area shape="poly" coords="831,830,841,830,848,831,855,832,855,802,830,802" href="moo.html" />
<area shape="poly" coords="856,832,872,838,884,839,884,802,856,802" href="moo.html" />
<area shape="poly" coords="885,839,910,841,910,810,885,810" href="moo.html" />
<area shape="poly" coords="910,841,909,810,937,809,937,848,925,844" href="moo.html" />
<area shape="poly" coords="937,848,938,810,964,810,964,850" href="moo.html" />
<area shape="poly" coords="964,850,989,852,999,853,1013,856,1023,857,1023,821,964,820" href="moo.html" />
<area shape="poly" coords="628,591,631,589,641,578,645,567,657,556,659,529,676,506,684,506,685,499,698,499,704,486,703,474,699,467,699,456,679,456,664,456,665,446,662,440,640,429,629,427,629,424,623,414,621,381,617,374,608,385,599,385,599,387,590,396,579,402,570,413,564,415,564,422,561,424,561,432,557,433,556,445,562,450,568,452,572,447,576,447,570,461,563,462,559,462,555,458,538,457,532,451,534,445,537,444,537,437,533,433,533,430,519,428,512,432,513,438,509,441,502,434,495,433,487,435,486,447,479,456,479,473,482,473,488,470,498,459,500,456,501,466,503,467,519,467,521,472,531,472,538,464,538,458,546,459,547,461,544,465,544,477,533,486,533,492,530,507,524,522,516,530,500,538,556,538,556,495,558,494,558,477,569,476,578,493,578,527,606,528,603,534,603,565,599,575,621,585,628,591" href="moo.html" />
</map><img name='map' src='getmap.php?map=1' usemap='mapdata' />

Slight modification - pushing it through the HTML validator, i’ve added alt=“” to all tags except map. The HTML validates, but still doesnt work.

Thanks for that. It’s now easier to see what the solution is, and I think that you may be right with the “something ridiculously easy” comment.

The # is missing from usemap=‘mapdata’

usemap='#mapdata'

… yup. As is often the case, a single punctuation mark threw the whole thing away, and it takes a second pair of eyes to see it.

Thanks!