Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic image maps 1

Status
Not open for further replies.

bezierstek

Programmer
Aug 30, 2007
43
FR
Hi all,

I am currently developing a property rental portal and as part of this my client wants to have country pages with a map which will have an image map lain over it. I only want to have the areas that have properties registered in in them to display the image map. I think I am right in thinking that I should be able to read from the database when there is a property in the area and use conditional statements to decide whether to display the maps or not.

Is this right or can anyone think of an easier way to do this?

Also related to this, as there are a large amount of countries/regions etc. I don't suppose anyone knows of an easy way to generate the maps rather than defining them all manually (a long shot I know).

To see the type of thing I mean, have a look at which should give you an idea of exactly what I am wanting to achieve.

Thanks,

Rich
 
Hi, I guess there are several ways to achieve this...

1) Implement google maps or the microsoft equalivent (they both offer code as example)
2) Use a map and make imagemap yourself

This is a sample for a non-advanced imagemap:
Code:
							<img id="imap" src="images/imap2.gif" width="109" height="109" border="0" alt="" usemap="#imap_Map" />
							<map name="imap_Map" id="imap_Map">
							<area shape="rect" id="prop1" onmouseover= "getProperty(1)" alt="Look at property" coords="41,40,67,66" href="#" />
													</map>

The problem here, is that you need to have the coords..
You would also need them in google maps, etc. but I think google maps implementation (or the ms eqalivent) would accept street-adress for the mapping purpose.

However, if your admin interface has a map-upload tool or map select-tool and you then use JS to get the coords from the image (click to get it), you could use ajax as a simple and quite effective way to select the right coords on a map of your own desire.

Its not too hard to store those positions into a db and on the output page, you parse the map as my code above, from the db-results.

I would think its 60-120 minutes work, if you think/google before you start.

Olav Alexander Mjelde
Admin & Webmaster
 
Thanks for that,

I will definitely be using our own maps rather than google maps so think I am going to have to make all the image maps myself (a pain but can't see anyway round it).

I'm definitely interested in the AJAX method you suggest so will be looking into it.

 
you should (easily) be able to convert the coordinates that you receive from the click (normal image coordinates) and convert them to latitude and logditude, then lookup the l/l coords to get the country name. v.simple and v.fast, i'd think.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top