Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<style type="text/css">
/*<![CDATA[*/
#map{
position:relative;width:200px;height:200px;background-Color:#FFCC66;
}
/*]]>*/
</style></head>
<body>
<table id="table" border="1">
<tr>
<td>Town</td>
<td>x</td>
<td>y</td>
</tr>
<tr>
<td>Town 1</td>
<td>450</td>
<td>50</td>
</tr>
<tr>
<td>Town 2</td>
<td>550</td>
<td>150</td>
</tr>
</table>
<div id="map" ></div>
<script type="text/javascript">
/*<![CDATA[*/
function Map(mapid,tableid){
var map=document.getElementById(mapid);
var rows=document.getElementById(tableid).rows;
for (var ary=[],cells,z0=1;z0<rows.length;z0++){
cells=rows[z0].cells;
ary.push([cells[0].innerHTML,cells[1].innerHTML,cells[2].innerHTML]);
}
var mark=zxcES('DIV',{position:'absolute',zIndex:'101',height:'30px',fontSize:'10px'});
zxcES('DIV',{position:'absolute',left:'0px',top:'15px',width:'30px',height:'1px',backgroundColor:'black'},mark);
zxcES('DIV',{position:'absolute',left:'15px',top:'0px',width:'1px',height:'30px',backgroundColor:'white'},mark);
for (var town,z1=0;z1<ary.length;z1++){
town=mark.cloneNode(true);
zxcES(town,{left:ary[z1][1]-400-15+'px',top:ary[z1][2]-15+'px'},map,ary[z1][0]);
}
}
function zxcES(ele,style,par,txt){
if (typeof(ele)=='string') ele=document.createElement(ele);
for (key in style) ele.style[key]=style[key];
if (par) par.appendChild(ele);
if (txt) ele.appendChild(document.createTextNode(txt));
return ele;
}
Map('map','table');
/*]]>*/
</script>
the co-ordinates for top left corner will be: x400, y0
the co-ordinates for top right corner will be: x599, y0
the co-ordinates for bottom left corner will be: x400, y199
the co-ordinates for bottom right corner will be: x599, y199
</body>
</html>
Bookmarks