<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    zhyiwww
    用平實(shí)的筆,記錄編程路上的點(diǎn)點(diǎn)滴滴………
    posts - 536,comments - 394,trackbacks - 0
    <html xmlns:v="http://m.tkk7.com/zhyiwww/">
    ?? ?<head>
    ?? ??? ?<title></title>
    ?? ??? ?
    ??????? <meta name="Generator" content="EditPlus" />
    ?? ??? ?<meta name="Author" content="eglic" />
    ?? ??? ?<meta name="ContentType" content="text/html" />
    ?? ??? ?<meta name="CharSet" content="GB2312" />
    ?? ??? ?
    ??????? <link rel="stylesheet" type="text/css" href="/style/default.css" />
    ?? ??? ?
    ??????? <style type="text/css">
    ??????????? v\:*?? {behavior:url(#default#VML);} ?
    ??????? </style>
    ?? ??? ?
    ?? ??? ?
    ?????? ?
    ?? ?</head>
    ?? ?<body>
    ?????? ?
    ?? ??? ?<div id='lineDiv'?? ??? ?
    ?? ??? ??? ?onmousedown = 'down(event)'?? ?
    ?? ??? ??? ?onmouseup='up(event)'
    ?? ??? ??? ?onmousemove='move(event)'
    ?? ??? ??? ?style='top:30px;left:30px;width:800px;height:600px;visibility:visible;border:solid 1px blue;background-color: #FF99FF'
    ?? ??? ?>?? ?
    ??????? ?
    ????? ?
    ????? </div>
    ?????? ?
    ??????? <script type="text/javascript">
    ?????? ?
    ?? ??? ??? ? /**
    ?? ??? ??? ? * 定義點(diǎn)對象,也就是鼠標(biāo)的位置的封裝
    ?? ??? ??? ? */
    ?? ??? ??? ?function Point(){
    ?? ??? ??? ??? ?return this;
    ?? ??? ??? ?}
    ?? ??? ??? ?Point.prototype.setX = function(screenX){
    ?? ??? ??? ?};
    ?? ??? ??? ?Point.prototype.setY = function(screenY){
    ?? ??? ??? ?}
    ?? ??? ??? ?
    ?? ??? ??? ?
    ?? ??? ??? ?/**
    ?? ??? ??? ? * 定義的屏幕點(diǎn)對象
    ?? ??? ??? ? */
    ?? ??? ??? ?function ScreenPoint(screenX,screenY){
    ?? ??? ??? ??? ?this.screenX = screenX;
    ?? ??? ??? ??? ?this.screenY = screenY;
    ?? ??? ??? ??? ?return this;
    ?? ??? ??? ?}
    ?????? ??? ?ScreenPoint.prototype = new Point();
    ?? ??? ??? ?
    ?? ??? ??? ?ScreenPoint.prototype.setX = function (screenX){
    ?? ??? ??? ??? ?this.screenX = screenX;
    ?? ??? ??? ?};
    ?? ??? ??? ?ScreenPoint.prototype.setY = function (screenY){
    ?? ??? ??? ??? ?this.screenY = screenY;
    ?? ??? ??? ?};
    ?? ??? ??? ?
    ?? ??? ??? ?/**
    ?? ??? ??? ? * 重載toString方法
    ?? ??? ??? ? */
    ?? ??? ??? ?ScreenPoint.prototype.toString = function(){
    ?? ??? ??? ??? ?return this.screenX.toString() + " ---? " + this.screenY.toString();
    ?? ??? ??? ??? ?//return "-----------";
    ?? ??? ??? ?}; ?
    ?? ??? ??? ?
    ??????? </script>
    ?????? ?
    ?? ??? ?<script language="javascript">
    ?? ??? ??? ?
    ?? ??? ??? ?// 你所點(diǎn)過的鼠標(biāo)位置的數(shù)組,是點(diǎn)對象數(shù)組
    ?? ??? ??? ?var disPoints = new Array();
    ?? ??? ??? ?

    ?? ??? ??? ?// 是否處于鼠標(biāo)按下狀態(tài)
    ?? ??? ??? ?var? select = false;
    ?? ??? ??? ?
    ?? ??? ??? ?// 記錄鼠標(biāo)按下點(diǎn)的位置 ,默認(rèn)是(0,0) ?
    ?? ??? ??? ?var? downX = 0; ?
    ?? ??? ??? ?var? downY = 0;
    ?? ??? ??? ?
    ?? ??? ??? ?// 當(dāng)前用于畫線的層?? ??? ??? ?
    ?? ??? ??? ?var lineDiv = document.getElementById("lineDiv");
    ?? ??? ??? ?
    ?? ??? ??? ?// 當(dāng)前你鼠標(biāo)畫的線,在鼠標(biāo)抬起前的那一條
    ?? ??? ??? ?var line = null;
    ?? ??? ??? ?
    ?? ??? ??? ?/**
    ?? ??? ??? ?* 處理鼠標(biāo)按下事件
    ?? ??? ??? ?*/
    ??????????? function down(event){?????????? ??? ?
    ?????????? ??? ?
    ?????????? ??? ?//alert(event);
    ?????????? ??? ?
    ?? ??? ??? ??? ?// 取得你選取的最后一個(gè)點(diǎn)
    ?? ??? ??? ??? ?var lastPoint = disPoints[disPoints.length - 1];
    ?? ??? ??? ??? ?//alert(lastPoint);
    ?? ??? ??? ??? ?
    ?? ??? ??? ??? ?// 判斷是否是第一個(gè)點(diǎn)
    ?? ??? ??? ??? ?if(lastPoint == null){
    ?? ??? ??? ??? ??? ?// 鼠標(biāo)按下點(diǎn)屏幕坐標(biāo)
    ?? ??? ??? ??? ??? ?var mouseX1 = event.clientX -? getDivOffsetLeft();
    ?? ??? ??? ??? ??? ?var mouseY1 = event.clientY -? getDivOffsetTop();
    ?? ??? ??? ??? ??? ?
    ?? ??? ??? ??? ??? ?// 記錄鼠標(biāo)按下點(diǎn)的屏幕坐標(biāo)
    ?? ??? ??? ??? ??? ?downX = mouseX1;
    ?? ??? ??? ??? ??? ?downY = mouseY1;
    ?? ??? ??? ??? ??? ?
    ?? ??? ??? ??? ??? ?// 記錄第一個(gè)點(diǎn)
    ?? ??? ??? ??? ??? ?lastPoint = new ScreenPoint(downX,downY);
    ?? ??? ??? ??? ??? ?disPoints[0] = lastPoint;
    ?? ??? ??? ??? ??? ?//return;
    ?? ??? ??? ??? ?}
    ?? ??? ??? ??? ?
    ?? ??? ??? ??? ?// 如果不是第一個(gè)點(diǎn)
    ?? ??? ??? ??? ?// 取得當(dāng)前鼠標(biāo)點(diǎn)的位置
    ?? ??? ??? ??? ?var mouseX2 = event.clientX -? getDivOffsetLeft();
    ?? ??? ??? ??? ?var mouseY2 = event.clientY -? getDivOffsetTop();
    ?? ??? ??? ??? ?
    ?? ??? ??? ??? ?// 定義當(dāng)前點(diǎn)
    ?? ??? ??? ??? ?var tmpPoint = new ScreenPoint(mouseX2,mouseY2);
    ?? ??? ??? ??? ??? ??? ??? ??? ?
    ?? ??? ??? ??? ?// 定義線的ID,用于,取得線的對象
    ?? ??? ??? ??? ?var lineID = "the_line_" + (disPoints.length-1);
    ?? ??? ??? ??? ?
    ?? ??? ??? ??? ?// 在當(dāng)前點(diǎn),和最后一個(gè)點(diǎn),兩點(diǎn)畫線
    ?? ??? ??? ??? ?line = drawLine(lineID,lastPoint,tmpPoint);
    ?? ??? ??? ??? ??? ??? ??? ?
    ?? ??? ??? ??? ?// 鼠標(biāo)按下,記錄按下的狀態(tài)
    ?? ??? ??? ??? ?select = true;
    ?? ??? ??? ??? ??? ?
    ??????????? }
    ?????????? ?
    ??????????? /**
    ?? ??? ??? ?* 處理鼠標(biāo)抬起事件
    ?? ??? ??? ?*/
    ?? ??? ??? ? function up(event){?? ??? ?
    ?? ??? ??? ? ?? ??? ?//alert("up");?? ??? ??? ?
    ?? ??? ??? ??? ??? ?// 取得鼠標(biāo)抬起點(diǎn)的坐標(biāo),也就是確定點(diǎn)的坐標(biāo)
    ?? ??? ??? ??? ??? ?var mouseX3 = event.clientX -? getDivOffsetLeft();
    ?? ??? ??? ??? ??? ?var mouseY3 = event.clientY -? getDivOffsetTop();
    ?? ??? ??? ??? ??? ?
    ?? ??? ??? ??? ??? ?// 最終確定的點(diǎn)的對象
    ?? ??? ??? ??? ??? ?var currentPoint = new ScreenPoint(mouseX3,mouseY3);
    ?? ??? ??? ??? ??? ?
    ?? ??? ??? ??? ??? ?// 把此點(diǎn)放入到線的端點(diǎn)數(shù)組里面,這個(gè)點(diǎn),相對于下一次的操作來說,就是最后一個(gè)點(diǎn)
    ?? ??? ??? ??? ??? ?disPoints[disPoints.length] = currentPoint;
    ?? ??? ??? ??? ??? ?select = false;?? ??? ?
    ?? ???????????? }?? ?
    ??????????? /**
    ?? ??? ??? ?* 處理鼠標(biāo)移動(dòng)事件
    ?? ??? ??? ?*/
    ?? ??? ??? ? function move(event){
    ?? ??? ??? ? ?? ??? ?// 是否鼠標(biāo)按下
    ?? ??? ??? ??? ??? ?if(select){?? ??? ?
    ?? ??? ??? ??? ??? ??? ?// 取得當(dāng)前鼠標(biāo)的位置坐標(biāo)
    ?? ??? ??? ??? ??? ??? ?var mouseX2 = event.clientX -? getDivOffsetLeft();
    ?? ??? ??? ??? ??? ??? ?var mouseY2 = event.clientY -? getDivOffsetTop();
    ?? ??? ??? ??? ??? ??? ?
    ?? ??? ??? ??? ??? ??? ?// 把線,從最后一個(gè)點(diǎn)畫到當(dāng)前位置
    ?? ??? ??? ??? ??? ??? ?line.to = mouseX2 + "," + mouseY2;?? ??? ??? ?
    ?? ??? ??? ??? ??? ?}
    ?? ??? ??? ??? ??? ?/*
    ?? ??? ??? ??? ??? ? * 取消事件冒泡,否則不能響應(yīng)鼠標(biāo)的抬起事件
    ?? ??? ??? ??? ??? ? */
    ?? ??? ??? ??? ??? ?window.event.cancelBubble = true;
    ?? ??? ??? ??? ??? ?window.event.returnValue = false;?? ?
    ?? ???????????? }?? ?
    ?????????? ?
    ?? ??? ??? ?
    ??????????? function getDivOffsetLeft(){
    ?? ??? ??? ??? ?var lay1 = document.getElementById("lineDiv");
    ?? ??? ??? ??? ?//var rect = document.getElementById("rect");
    ?? ??? ??? ??? ?return lay1.offsetLeft;
    ?? ??? ??? ?}
    ?? ??? ??? ?function getDivOffsetTop(){
    ?? ??? ??? ??? ?var lay1 = document.getElementById("lineDiv");
    ?? ??? ??? ??? ?//var rect = document.getElementById("rect");
    ?? ??? ??? ??? ?return lay1.offsetTop;
    ?? ??? ??? ?}
    ?? ??? ???? ?
    ?? ??? ???? ?
    ??? ?
    ?? ??? ???? /**?? ??? ??????? ?
    ?? ??? ???? * 畫線操作
    ?? ??? ???? * 用VML 實(shí)現(xiàn)
    ?? ??? ???? */
    ?? ??? ??? ?function drawLine(id,startPoint,endPoint){
    ?? ??? ??? ??? ?//alert("start -- ");
    ?? ??? ??? ???? var?? s="<v:line?? " +
    ?? ??? ??? ??? ??? ?+ ?? ?"id="
    ?? ??? ??? ??? ??? ?+ ?? ?id
    ?? ??? ??? ??? ??? ?+?? ?"?? from="
    ?? ??? ??? ??? ??? ?+?? ?"'"
    ?? ??? ??? ??? ??? ?+ ?? ?startPoint.screenX
    ?? ??? ??? ??? ??? ?+?? ?","
    ?? ??? ??? ??? ??? ?+ ?? ?startPoint.screenY
    ?? ??? ??? ??? ??? ?+?? ?"'"
    ?? ??? ??? ??? ??? ?+ ?? ?"?? to="
    ?? ??? ??? ??? ??? ?+ ?? ?"'"
    ?? ??? ??? ??? ??? ?+ ?? ?endPoint.screenX
    ?? ??? ??? ??? ??? ?+?? ?","
    ?? ??? ??? ??? ??? ?+ ?? ?endPoint.screenY
    ?? ??? ??? ??? ??? ?+?? ?"'"
    ?? ??? ??? ??? ??? ?+?? ?"? style='position:absolute;left:0px;top:0px;'></v:line>";
    ?? ??? ??? ?
    ?? ??? ??? ??? ?var? o = document.createElement(s);?

    ??? ?? ?? ?? ?? // 這個(gè)方法,使在特定的位置添加對象,具體使用,請參考其它的資料
    ?? ??? ??? ??? ?document.body.insertAdjacentElement('BeforeEnd',o); ?
    ?? ??? ??? ??? ?
    ?? ??? ??? ??? ?return o;
    ?? ??? ??? ?}
    ?? ??? ??? ?
    ?? ??? ??? ?
    ?? ??? ?</script>
    ?? ?</body>
    </html>



    |----------------------------------------------------------------------------------------|
                               版權(quán)聲明  版權(quán)所有 @zhyiwww
                引用請注明來源 http://m.tkk7.com/zhyiwww   
    |----------------------------------------------------------------------------------------|
    posted on 2007-04-05 19:32 zhyiwww 閱讀(8441) 評論(11)  編輯  收藏 所屬分類: gisvml

    FeedBack:
    # re: javascript鼠標(biāo)畫線的VML實(shí)現(xiàn)
    2007-04-06 13:05 | BeanSoft
    先支持一下  回復(fù)  更多評論
      
    # re: javascript鼠標(biāo)畫線的VML實(shí)現(xiàn)
    2007-07-09 15:20 | ~~
    Good~~~~  回復(fù)  更多評論
      
    # re: javascript鼠標(biāo)畫線的VML實(shí)現(xiàn)
    2007-11-09 16:40 | 馬大哈
    先頂一下 太好了 謝謝樓主  回復(fù)  更多評論
      
    # re: javascript鼠標(biāo)畫線的VML實(shí)現(xiàn)
    2007-11-21 15:51 | irene
    謝謝樓主,頂一個(gè)!
    不過要如何控制畫線結(jié)束呢?  回復(fù)  更多評論
      
    # re: javascript鼠標(biāo)畫線的VML實(shí)現(xiàn)
    2007-11-21 23:56 | vml
    是啊
    要是能夠控制畫線的結(jié)束就好了額
    不過還是謝謝哈!  回復(fù)  更多評論
      
    # re: javascript鼠標(biāo)畫線的VML實(shí)現(xiàn)
    2007-11-23 09:33 | zhyiwww
    這幾天沒有時(shí)間了,等些天,如果有時(shí)間,再修改一下,完善一下功能.  回復(fù)  更多評論
      
    # re: javascript鼠標(biāo)畫線的VML實(shí)現(xiàn)
    2007-11-24 21:21 | vml
    等待你的修改哦 我也一直在想這個(gè)問題,但是水平有限啊!弄不出來
    不想的能不能夠?qū)崿F(xiàn)在屏幕上添加一個(gè)按鈕 這樣點(diǎn)一下按鈕就可以畫一個(gè)點(diǎn) 或者畫一條線 能夠?qū)崿F(xiàn)這樣的就好了  回復(fù)  更多評論
      
    # re: javascript鼠標(biāo)畫線的VML實(shí)現(xiàn)
    2008-01-15 14:01 | gis_cn
    能不能加上這個(gè)功能呢, 線畫好后, 每個(gè)點(diǎn)都是可以拖動(dòng)的, 這樣可以調(diào)整線  回復(fù)  更多評論
      
    # re: javascript鼠標(biāo)畫線的VML實(shí)現(xiàn)[未登錄]
    2008-03-08 10:51 |
    謝謝!  回復(fù)  更多評論
      
    # re: javascript鼠標(biāo)畫線的VML實(shí)現(xiàn)
    2008-04-27 15:24 | sk
    不錯(cuò),謝了  回復(fù)  更多評論
      
    # re: javascript鼠標(biāo)畫線的VML實(shí)現(xiàn)
    2009-03-20 17:42 | 是是非非
    <meta name="Author" content="eglic" />

    都不記得啥時(shí)候?qū)懙牧恕!!?nbsp; 回復(fù)  更多評論
      
    主站蜘蛛池模板: 国产精品视频免费一区二区| 国产亚洲成人久久| 国产偷国产偷亚洲高清日韩 | 野花视频在线官网免费1| 最近中文字幕完整版免费高清| 久久久久国产成人精品亚洲午夜| 美女视频黄免费亚洲| 久久综合亚洲色一区二区三区| 一级一级一片免费高清| 国产国拍精品亚洲AV片| 另类免费视频一区二区在线观看| 亚洲国产综合无码一区 | 国产精品成人免费一区二区| 日韩精品久久久久久免费| 亚洲日韩在线视频| 色播在线永久免费视频| 99久久国产亚洲综合精品| 精品国产一区二区三区免费看| 成人免费观看一区二区| 美女隐私免费视频看| 香蕉视频免费在线播放| 又硬又粗又长又爽免费看 | 精品亚洲永久免费精品| 无码中文字幕av免费放dvd| 亚洲视频无码高清在线| 香蕉视频免费在线| 99精品视频免费在线观看| 免费无码黄网站在线观看| 狠狠色婷婷狠狠狠亚洲综合 | 夜夜爽妓女8888视频免费观看 | 香蕉高清免费永久在线视频| 亚洲午夜福利精品无码| 在线观看免费大黄网站| 91福利视频免费| 真实乱视频国产免费观看| 亚洲精品和日本精品| 日韩免费高清视频| 在人线av无码免费高潮喷水| 日韩精品极品视频在线观看免费| 在线观看免费为成年视频| 久久亚洲国产中v天仙www|