USEMAP with separate map files and database

Posted on 2002-05-21
Last Modified: 2010-04-09

I'm trying to load maps from a separate map file for maintenance purposes.

contents of demo.htm file
<img src="myimage.gif" usemap="canada.htm#canada">

contents of canada.htm file
<map name=canada>
<area name=BritishColumbia shape="rect" coords="0, 0, 250, 250" href="bc.htm">
<area name=Alberta shape="rect" coords="0, 250, 250, 250">
etc etc etc

can someone PLEASE explain to me why this doesn't work.  Every website I've been to has something similar to this as an example.  Is this functionality that has been dropped from the DOM in recent releases?

I have an ASP page which is built from the content of a table in a database and need to be able to pull the relevant map file for the image.  i.e. if someone selects USA, then I need it to pull the map as well as the coordinate file from the database.  I can get it to build the page without any problems, it's just that when I do this, my imagemaps won't work.

Thanks for any help.
Question by:balabaster
  • 4
  • 4
  • 2
  • +1
LVL 22

Expert Comment

ID: 7026487
Looks okay to me. Are you sure that the map is correct too?

<img src="myimage.gif" usemap="canada.htm#canada" ISMAP>
LVL 22

Expert Comment

ID: 7026491
Does it work for you, if both the map and image are in the same file?


Expert Comment

ID: 7026588
When I was trying to do the same (and also discussed the problem with other coders), I came to a conclusion that it's impossible.

However when placed in one file, it works just fine.
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

LVL 19

Expert Comment

ID: 7026860
You can do it as an include, that would work.

But try it as a TEXT file, not HTML. Rename the file to canada.txt and see what happens.

Author Comment

ID: 7028249
CJ S:  Yes the image and the map both work in the same file.  The only thing is, I have 10 countries in the database currently and would need to include 10 image maps in my html, not something I want to do, as in 2 weeks, I am likely to have 100 countries, and 100 maps, and I don't want 100 maps in my HTML, it's a waste of download time.


Leveret: I'm rapidly coming to the same conclusion.  Of course, the HTML 3.2 Specification dictates that it should work, but I guess Microsoft & Netscape in their infinite wisdom decided that design specifications aren't important in this world anyway.  Who am I to argue? I'm just a lowly programmer who just has to work around their shortcomings.


WebWoman: Okay, I understand the include, I can do do I get it to determine which page to include by getting the info from the database?  I've been trying to use this work around, but I can't figure out how.

The following code generates the correct string, but then it promptly decides to dump that literal into the HTML instead of including the file.

Response.Write "<!-- #include virtual="& oRec("MapFile") &" -->"

I understand why it does this, response.write tells it to write that into the HTML, it doesn't tell it to include it as #include does.  Any clues how I would make it include dynamically?
LVL 19

Accepted Solution

webwoman earned 50 total points
ID: 7028294
You can't. You can use an if/elseif construction to check through a list of various includes, but you can't use a variable name as the include.

You can store the map info in the datbase, code and all (it's just text, after all), and insert THAT instead of using an include. That works too.

So instead of the include you'd use
<%= rs("mapinfo") %>
where you want the map info to show up.
(response.write is too confusing for me... ;-) )
LVL 19

Expert Comment

ID: 7028300
Of course, if you're going to pull that info from a database, you need to have a unique number for the record (or some unique identifier) AND you need to pass that to the map page so you know what to pull from the database.

Have you done that before? And did you try changing the map info to a TXT file extension?

Author Comment

ID: 7028341
webwoman: yeppers, been there done that...the txt file extension gives me the same aggravation.

With regards to putting the map coordinate info *in* the database, I'd already thought about this, but can't come up with a satisfactory way of putting the info in the database...I don't know if you've seen a coordinate file for a country like the U.S., but it's a mile long.  Putting it into the database is almost as big a headache as trying to get imagemaps in separate files to work.  If this is the only way to do it, then I guess I'm gonna go that route...eek.

Any more ideas would be most welcome.  Why oh why can't software providers implement *anything* on spec?  Anybody working for Microsoft & Netscape.  TAKE HEED TO THAT!


Author Comment

ID: 7028529
Well, I guess technically the answer is excellent, although it sucks that this is the only way to do it, so well done.

I've loaded the contents of all my map files into my database and am doing it that way, grrrr.  It works though.

Thanks anyway.
LVL 19

Expert Comment

ID: 7028577
I know what you mean... I wish they'd come up with a better way too. I've got entire press releases, with links to pics, tables, tons of HTML code, in my database. It sure would be a whole lot easier if I could just put the include file name there...

Thanks for the A!

Author Comment

ID: 7028580
Well you would think that you wouldn't need to load down your database with all that data.  Maybe this hasn't been presented to Microsoft/Netscape yet.

No problems with the (A) I hope ;)

Talk to you again possibly.

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question