
window.onload=canvasMap;
function canvasMap(){
  var canvas = document.getElementById("canvasMap");
  var ctx = canvas.getContext("2d");
  var x = $("#movex").val();
  var y = $("#movey").val();
  var z = $("#movez").val();
  var a = $("#movea").val();

  ctx.beginPath();
  ctx.fillStyle = "#808080";
  ctx.arc(100,100,100,0,Math.PI*2,true);
  ctx.fill();
  ctx.closePath();


  canvas.addEventListener("mousedown",function(e){
    $.ajax({
      type:"GET",
      url:"http://"+UrlElement['sendIpAddress']+
      ":"+UrlElement['sendPortNumber']+
      "/"+UrlElement['sendManufacturer']+
      "/set/stagea?x="+encodeURIComponent(x)+
      "&y="+encodeURIComponent(y)+
      "&z="+encodeURIComponent(z)+
      "&a="+encodeURIComponent(z),
      success: function(data){
        console.log(data);
      }
    });
  });
}

function canvasMapDraw(){
  var step = (1/2000);//倍率変化はここの通知を変化
  var canvas = document.getElementById("canvasMap");
  var ctx = canvas.getContext("2d");
  var x = $("#movex").val();
  var y = $("#movey").val();
  if(x == 0 || y==0){
  ctx.beginPath();
  ctx.fillStyle = "#000000";
  ctx.moveTo(100,100);
  ctx.lineTo((parseInt(x)*step)+100,-(parseInt(y)*step)+100);
  //ctx.lineTo(150,100)
  ctx.closePath();
  ctx.stroke();
  moveX = (parseInt(x)*step)+100;
  moveY = -(parseInt(y)*step)+100;
}
  else if(x !=0 || y!= 0){
  ctx.beginPath();
  ctx.fillStyle = "#000000";
  ctx.moveTo(moveX,moveY);
  ctx.lineTo((parseInt(x)*step)+100,-(parseInt(y)*step)+100);
  //ctx.lineTo(150,100)
  ctx.closePath();
  ctx.stroke();
  moveX = (parseInt(x)*step)+100;
  moveY = -(parseInt(y)*step)+100;
}
}
