您的位置:首页 > Web前端 > JQuery

mapXtreme for java测距仿于51地图测距(前台部分,用JQuery + dwr + vml)

2010-06-12 16:23 197 查看
//测距
var lineDis = 0;
var lineUtil = "m";
function drawline(){
if(state=="line"){
var mWorkLine=true;
var formX,formY,toX,toY;
lineDis = 0;
var mParentDiv = $("<div></div>")
mParentDiv.appendTo("#imgmap");
$("#imgmap").bind("mousedown", function(){
if (mWorkLine){
if(formX==undefined && toY==undefined){
formX=window.event.x;
formY=window.event.y;
mParentDiv.css({'position': 'absolute'});
return false;
}
toX=window.event.x;
toY=window.event.y;
$("<v:Line></v:Line>").attr("id", "line_"+formX+"_"+formY+"_"+toX+"_"+toY)
.attr("from", formX + "," + formY)
.attr("to", toX + "," + toY)
.attr("strokecolor", "red")
.attr("strokeweight", "3px")
.appendTo(mParentDiv);
loadDwr.getDis(formX,formY,toX,toY,lineDis,lineUtil,{callback:function(data){
lineUtil = data.substring(data.indexOf("|")+1,data.length);
lineDis =data.substring(0, data.indexOf("|"));
$("<div></div>").css({'top' : toY,
'left': toX,
'position': 'absolute',
'border': '#adaeac 1px solid',
'background-color': '#fbfbd9'})
.html(lineDis+lineUtil)
.appendTo(mParentDiv);
}});
formX=toX;
formY=toY;
}
});
$("#imgmap").bind("mousemove", function(){
if (mWorkLine){
if(formX==undefined && toY==undefined){return false; }
if(formX==window.event.x && toY==window.event.y){return false;}
if(document.getElementById("TempLine")){document.getElementById("TempLine").outerHTML=""}
$("<v:Line></v:Line>").attr("id", "TempLine")
.attr("from", formX + "," + formY)
.attr("to", window.event.x + "," + window.event.y)
.attr("strokecolor", "red")
.attr("strokeweight", "3px")
.appendTo(mParentDiv);
}
});
$("#imgmap").bind("dblclick", function(){
mWorkLine = false;
$("#imgmap").unbind("mousedown");
$("#imgmap").unbind("mousemove");
$("#imgmap").unbind("dblclick");
$("<img>").css({'top':formY,
'left':formX-10,
'cursor': 'pointer',
'position': 'absolute'})
.attr("src","./51/del.gif")
.attr("title", "清除本次测距")
.bind("click",function(){
$(this).parent().remove();
})
.appendTo(mParentDiv);
resetimg();
state = "";
document.getElementById("TempLine").outerHTML="";
})
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐