View Full Version : Map Area

05-14-2009, 01:52 AM
This isn't for a site or anything a friend of mine likes to through scripts at me to get my skills up but this got me big time. Basically I'm supposed to add an image to the map area using javascript, here's the code:

<title>Good Luck - hahaha</title>
<style type="text/css">
#map_stuff .mapper {background-image:url(someImage.gif)}

<div id="map_stuff">
<div id="1" class="mapper" >
<map id="this_map" name="this_map">
<area id="a" shape="circle" coords="139,58,31" title="" href="somePHPsite.php" />


I have to put and image into the map and remove any other images.... any help would be appreciated.

Old Pedant
05-14-2009, 05:44 AM
This friend wouldn't happen to be an instructor at some school, would he?

Those are terribly vague requirements. How big an image? Where?

And what "other images"? There are none shown there.

That code you show there would seem to indicate that the image removal/addition should take place in PHP code, since the HREF is pointing to a PHP page.

So are you supposed to do this in PHP or in JavaScript??

rnd me
05-14-2009, 01:21 PM
you add map areas to images, not the other way around.
This must be done by hand, not by a script.

How would a script know what areas of an image are to link to what server?

It needs a human touch, unless you are talking very primitive images, and even then you really don't want to do image processing in javascript, you won't have much luck.

@old pendant:
This is a client-side image map, the href indicates to the server the portion of the image that was clicked.
examples include click on faces in a crowd for more info on him, choose your country, etc...

If i understand the OP, i think he wants to define additional clickable regions to an existing image tag.
While javascript certainly can create those connections using the DOM, i don't see from what info it would do so.

Old Pedant
05-14-2009, 08:44 PM
Yes, I know it's a client side map. And my comment was *specifically* because of the HREF in there; when he clicks on that area it's going to go back to that page on the server. So he *could* then produce an entirely new page via PHP and send it back, with different images. Clumsy and slow, but it could be done that way.

But I'm sure that's not what his instructor is after. Excuse me, his friend.

rnd me
05-14-2009, 11:57 PM
yes, if he were on the same domain.

But server-side image maps are frowned upon for accessibility, so it would be better to return only a sucsess message, and rebuild the map client-side.

just my $0.02

Old Pedant
05-15-2009, 12:07 AM
100% agreed. I just don't think he yet knows what he needs.