我已经能够使用按钮(图像映射器)设置地图坐标,但是当我加载新图像时无法重新绑定到新坐标。
我有一个图像和映射,然后我用一个按钮更改图像。我还想更改映射坐标并为不同的图像显示不同的映射。任何帮助都会很棒谢谢
<body>
<img src="images/line 1.jpg" id = "boxx" alt="boxx" name="boxx" width="800" height="435" usemap="#box" />
<map name="box" id ="box" >
<area id="A" shape="rect" state= "A" coords="68,133,187,302" href="#" />
<area id="B" shape="rect" state= "B" coords="192,160,360,311" href="#" />
<area id="C" shape="rect" state= "C" coords="324,120,467,271" href="#" />
<area id="D" shape="rect" state= "D" coords="474,122,595,241" href="#" />
<area id="E" shape="rect" state= "E" coords="597,119,766,240" href="#" />
<area id="F" shape="rect" state= "F" coords="437,278,805,367" href="#" />
<area id="G" shape="rect" state= "A" coords="29,318,799,336" href="#" />
<area id="H" shape="rect" state= "B" coords="30,338,799,356" href="#" />
<area id="I" shape="rect" state= "C" coords="30,358,804,376" href="#" />
<area id="J" shape="rect" state= "D" coords="31,376,798,395" href="#" />
<area id="K" shape="rect" state= "E" coords="31,394,798,412" href="#" />
<area id="L" shape="rect" state= "F" coords="31,413,796,434" href="#" />
</map>
<input name="new" id = "b" value = "b"type="button" onclick = "change(this);" />
<input name="ne" id = "c" value = "c"type="button" onclick = "change(this);" />
<script>
function change(bu)
{
var box1 = document.getElementById("A");
var box2 = document.getElementById("B");
var box3 = document.getElementById("C");
var box4 = document.getElementById("D");
var box5 = document.getElementById("E");
var box6 = document.getElementById("F");
var box7 = document.getElementById("G");
var box8 = document.getElementById("H");
var box9 = document.getElementById("I");
var box10 = document.getElementById("J");
var box11= document.getElementById("K");
var box12= document.getElementById("L");
if ((bu.value) == "c")
{
var img = document.getElementById("boxx");
img.src = "images/Line 3.jpg";
box1.coords ="143,127,200,251";
box2.coords ="202,127,329,252";
box3.coords ="330,127,450,252";
box4.coords ="453,125,717,253";
box5.coords ="727,126,831,244";
box6.coords ="454,256,717,284";
box7.coords ="26,330,732,352";
box8.coords ="31,353,734,371";
box9.coords ="26,376,731,394";
box10.coords ="34,396,740,415";
box11.coords ="23,287,728,307";
box12.coords ="32,417,735,436";
}
//var button = document.getElementById("b");
var bb = bu.value;
alert(bb);
var button1 = "#" + bb;
alert (button1);
//image1.mapster('unbind');
$(button1).bind('click',function()
{
var image1 = $('#boxx');
alert (A.coords);
alert (G.coords);
alert("unbind");
var options = {
mapKey: 'state',
fillColor: 'd42e16',
fillOpacity: 0.3
};
//image1.mapster(options);
image1.mapster('rebind',options);
});
}
</script>