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.
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

770 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