HTML5_05之SVG擴充、地理定位、拖放

來源:互聯網
上載者:User

標籤:...   height   反向   文本   特性   rect   body   模組   text   

1、SVG繪圖總結:
 ①方法一:已有svg檔案,<img src="x.svg">
  方法二:<body><svg></svg></body>
 ②繪製矩形:<rect x="" y="" width="" height=""></rect>
 ③繪製圓形:<circle cx="" cy="" r=""></circle>
 ④繪製橢圓:<ellipse cx="" cy="" rx="" ry=""></ellipse>
 ⑤繪製直線:<line x1="" y1="" x2="" y2=""></line>
 ⑥繪製折線:<polyline points="x1,y1 x2,y2 ..."></polyline>
 ⑦繪製多邊形:<polygon points="x1,y1 x2,y2 ..."></polygon>
 ⑧繪製文本:<text x="" y="" font-size="">XXX</text>
 ⑨繪製映像:<image xlink:href=""></image>
 ⑩使用漸層:
 linearGradient:線性漸層;
 <svg>
  <defs>
   <linearGradient id="g1" x1="" y1="" x2="" y2="">
    <stop offset="0" stop-color="" stop-opacity="">
   </linearGradient>
  </defs>
  <rect fill="url(#g1)" stroke="url(#g1)"></rect>
 </svg>
2、SVG濾鏡(filter)——對映像進行像素化處理:
 feGaussianBlur:高斯模糊濾鏡;
 <defs>
  <filter id="f1">
   <feGaussianBlur stdDeviation="5"></feGaussianBlur>
  </filter>
  <rect filter="url(#f1)"></rect>
 </defs>
3、第三方繪圖工具庫——Two.js:
 <div id="container"></div>
 <script src="js/two.js"></script>
 <script>
  var two=new Two({}).appendTo(container);
  two.makeCircle(...);
  two.makeRectangle(...);
  //two.update();
  //two.play();
 </script>
4、HTML5新特性——地理定位:
 ①window.navigator.geolocation:擷取當前瀏覽器所在的地理位置;
 經度——longitude;維度——latitude;海拔——altitude;速度——speed;
 ②手機使用內建GPS模組或是訊號基站,PC使用IP地址反向解析;
 ③瀏覽器地理定位涉及個人隱私,詢問許可權:
  navigator.geolocation{
   getCurrentPosition:fn,//一次性擷取定位資訊
   watchPosition:fn,//周期性監視定位資訊
   clearWatch:fn//清除定位監視器
  }
 ④使用:
  navigator.geolocation.getCurrentPosition(
   function(pos){//擷取成功
    console.log(pos.coords.longtude);//經度
    console.log(pos.coords.latitude);//維度
    console.log(pos.coords.altitude);//海拔
    console.log(pos.coords.speed);//速度
   }
   function(err){//擷取失敗
    console.log(err.code);
    console.log(err.message);
   }
  );
5、調用百度地圖API:
 查看使用JS調用百度地圖說明文檔——http://lbsyun.baidu.com/index.php?title=jspopular
6、HTML新特性——拖放API(Drag & Drop):
 ①被拖動對象——來源物件(source)觸發事件:
  ondragstart——拖動開始;ondrag——拖動中;ondragend——拖動結束;
 ②可拖著進入並鬆手的對象——目標對象(target)觸發事件:
  ondragenter——拖著進入上方;ondragover——拖著在上方懸停;ondrop——鬆開;ondragleave——拖動著離開;
 ③ondragover事件後續預設行為是ondragleave,即ondragover後預設必然觸發ondragleave,使用時須阻止瀏覽器此預設行為;

HTML5_05之SVG擴充、地理定位、拖放

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.