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="";
})
}
}
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="";
})
}
}
相关文章推荐
- 仿51地图的测面积(前台部分)用JQuery + dwr + vml
- struts2 + ajax(由前台的form提交数据到后台,再根据form所调用返回获取的后台json格式的数据返回到前端,然后前端用jquery对json数据进行解析)==》》涉及文件上传的部分
- struts2 + ajax(由前台的form提交数据到后台,再根据form所调用返回获取的后台json格式的数据返回到前端,然后前端用jquery对json数据进行解析)==》》涉及非文件上传的部分
- jquery.flot.js 生成的图表无法在IE6及部分IE8上显示的问题之一 'window.G_vmlCanvasManager' 为空或不是对象
- jQuery的jVectorMap矢量地图用法(部分功能实现)
- dwr跟 jquery的$冲突解决方法
- jquery 前台数据验证
- Ajax (部分一)自己做的,总结页面向后台传Form值、单个值和后台向前台传一个或是一组值
- 如何编写51单片机超声波测距SR04_lcd1602显示程序
- jquery控制页面部分刷新的方法
- jquery控制页面部分刷新的方法
- jQuery 中的ajax部分
- jQuery根据纬度经度查看地图
- 设置超链接jQuery输入城市查看地图
- jQuery根据纬度经度查看地图
- extjs实现选择多表自定义查询功能 前台部分(ext源码)
- 工作笔记总结——前台js—jQuery—HTML
- jquery.validate 验证(支持前台js验证通过,然后ajax后台数据校验)二
- 20+个很有用的 jQuery 的 Google 地图插件
- 使用 jQuery,第 1 部分: 将桌面应用程序引入浏览器