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

//测距
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="";
  })
 }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值