Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi!!!

I was wondering if it's possible to create an Image Map dinamically. I'm working with MVC with c# and asp.net.

What I have is this:
An Arraylist with ant itemCoor, that have inside the coordinate's X and Y for each point that I have to draw:

ArrayList points= new ArrayList();
int[] itemCoor = new int[2];
itemCoor[0] = 1;
itemCoor[1] = 100;
points.Add(itemCoor);
.....


Obviously, every time I need to draw the image map over an image, it's in a different image and with diferent arraylist of coordinates.

and what I need to do is to draw an Image map with small circles in each pair of coordinates. I have to go over the arraylist, searching for the coordinates, and dinamically creating the image map.

Is it possible?

THANKS A LOT!!!
Posted
Updated 9-Jun-10 2:09am
v2

Yes, this can be done (and has been). You can dynamically change the map tags content (or even individual area tags within) using simple JavaScript. Have done so in a number of projects. Works with all major browsers.

Basic steps:
1. Fetch data
2. Create a new area node.
3. Set its inner html. (remember to set an id so you can refer to it later)
4. Add element to the map parent.

done
 
Share this answer
 
Comments
charly_fer 10-Jun-10 5:01am    
1. Fetch data.
Done!!
2. Create a new area node.
In aspx file, I do this:
I can't put it with the less and greater sing's sorry!! :(

map name="map_name" id="map1"
area alt="Waiting for information" shape="rect" coords="200,200,250,250" href="http://whatever.com" It's just an example of what I need!
..............---> I have to take it from my vector in aspx.cs!!!

3. Set its inner html. (remember to set an id so you can refer to it later)
4. Add element to the map parent.
How do I do this?


Thanks a lot!!!
I am not sure that I completely understand what it is that you are trying to do.

However, one thing from your existing code. It might be more advantageous to change it to:
C#
  ArrayList points= new ArrayList();
  points.Add(new Point(1, 100));
.....

as, if you are drawing the chances are that you will have to convert your itemCoor to a Point at some time. As I said earlier, though, this would depend on exactly what it is that you are trying to do.

Later, you talk about drawing circles and for that you will need more than just an X and a Y coordinate.

So if you could explain your problem slightly differently, you might get more help
 
Share this answer
 
Comments
charly_fer 10-Jun-10 4:54am    
Thanks for your answer. It's just an example. What I have to do it's to reuse an ArrayList that I create before with four int Data inside, for each element in the ArrayList. The first and the second one are the coordinates X and Y, the other ones are not relevant to draw the points It's volume and color information!! ;)

The question is that I process and Image with an external software, and then, I create an Arraylist with a variable number of points from the image, and after that, what I need to do it's to create a dynamic image map with that info over a copy of the Image.

I apologized if I'm not using the better way to make you understand me. It's my mistake!!

Thank you again!!!
Ok!!

This is what I did.

In aspx page, I wrote
]]>

And in aspx.cs, I wrote
protected void function(){
String prueba="";
Response.Write(prueba);
}

And It works!!!

Thank you guys!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900