乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      第三篇 Arcgis api for js之dojo框架使用

       SecondChoice 2018-06-10

      學(xué)習(xí)要點(diǎn):

      1、dojo框架;

      2、dojo框架下類的定義與繼承;

      3、dojo資源:

      http:///api/

      http:///download/

      http:///documentation/tutorials/1.10/hello_dojo/


      最近在研究arcgis js api,但好像不可避免要遇到dojo框架的學(xué)習(xí)與使用,因?yàn)閍rcgis js api就是基于dojo開發(fā)的。

      思路:1、本地部署好arcgis js api(過程略);2、dojo簡(jiǎn)單實(shí)例代碼;3、dojo類的定義與繼續(xù);



      一、官網(wǎng)實(shí)例

      實(shí)例1:

      1. <!DOCTYPE html>  
      2. <html>  
      3. <head>  
      4.     <meta charset="utf-8">  
      5.     <title>Tutorial: Hello Dojo!</title>  
      6. </head>  
      7. <body>  
      8.     <h1 id="greeting">Hello</h1>  
      9.     <!-- load Dojo -->  
      10.     <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"  
      11.             data-dojo-config="async: true"></script>  
      12. </body>  
      13. </html>  

      這個(gè)實(shí)例中引用了dojo CDN官網(wǎng)api,試了下,并不好用,還是換成自己本地部署的api好使;


      實(shí)例2

      1. <!DOCTYPE html>  
      2. <html>  
      3. <head>  
      4.     <meta charset="utf-8">  
      5.     <title>Tutorial: Hello Dojo!</title>  
      6. </head>  
      7. <body>  
      8.     <h1 id="greeting">Hello</h1>  
      9.     <!-- load Dojo -->  
      10.     <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"  
      11.             data-dojo-config="async: true"></script>  
      12.   
      13.     <script>  
      14.         require([  
      15.             'dojo/dom',  
      16.             'dojo/dom-construct'  
      17.         ], function (dom, domConstruct) {  
      18.             var greetingNode = dom.byId('greeting');  
      19.             domConstruct.place('<em> Dojo!</em>', greetingNode);  
      20.         });  
      21.     </script>  
      22. </body>  
      23. </html>  

      輸出結(jié)果為:Hello Dojo!


      實(shí)例3,類的定義與調(diào)用。定義一個(gè)js類,然后在html頁(yè)面中調(diào)用



      myModule.js

      1. define([  
      2.     // The dojo/dom module is required by this module, so it goes  
      3.     // in this list of dependencies.  
      4.     'dojo/dom'  
      5. ], function(dom){  
      6.     // Once all modules in the dependency list have loaded, this  
      7.     // function is called to define the demo/myModule module.  
      8.     //  
      9.     // The dojo/dom module is passed as the first argument to this  
      10.     // function; additional modules in the dependency list would be  
      11.     // passed in as subsequent arguments.  
      12.   
      13.     var oldText = {};  
      14.   
      15.     // This returned object becomes the defined value of this module  
      16.     return {  
      17.         setText: function (id, text) {  
      18.             var node = dom.byId(id);  
      19.             oldText[id] = node.innerHTML;  
      20.             node.innerHTML = text;  
      21.         },  
      22.   
      23.         restoreText: function (id) {  
      24.             var node = dom.byId(id);  
      25.             node.innerHTML = oldText[id];  
      26.             delete oldText[id];  
      27.         }  
      28.     };  
      29. });  

      hellodojo.html

      1. <!DOCTYPE html>  
      2. <html>  
      3. <head>  
      4.     <meta charset="utf-8">  
      5.     <title>Tutorial: Hello Dojo!</title>  
      6. </head>  
      7. <body>  
      8.     <h1 id="greeting">Hello</h1>  
      9.     <!-- configure Dojo -->  
      10.     <script>  
      11.         // Instead of using data-dojo-config, we're creating a dojoConfig  
      12.         // object *before* we load dojo.js; they're functionally identical,  
      13.         // it's just easier to read this approach with a larger configuration.  
      14.         var dojoConfig = {  
      15.             async: true,  
      16.             // This code registers the correct location of the "demo"  
      17.             // package so we can load Dojo from the CDN whilst still  
      18.             // being able to load local modules  
      19.             packages: [{  
      20.                 name: "demo",  
      21.                 location: location.pathname.replace(/\/[^/]*$/, '') + '/demo'  
      22.             }]  
      23.         };  
      24.     </script>  
      25.     <!-- load Dojo -->  
      26.     <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script>  
      27.   
      28.     <script>  
      29.         require([  
      30.             'demo/myModule'  
      31.         ], function (myModule) {  
      32.             myModule.setText('greeting', 'Hello Dojo!');  
      33.   
      34.             setTimeout(function () {  
      35.                 myModule.restoreText('greeting');  
      36.             }, 3000);  
      37.         });  
      38.     </script>  
      39. </body>  
      40. </html>  


      在上面這個(gè)實(shí)例中,實(shí)現(xiàn)了js類的定義與調(diào)用,但在html頁(yè)面中有個(gè)段代碼需要注意,沒有這段代碼無法實(shí)現(xiàn)調(diào)用

      1. <script>  
      2.         // Instead of using data-dojo-config, we're creating a dojoConfig  
      3.         // object *before* we load dojo.js; they're functionally identical,  
      4.         // it's just easier to read this approach with a larger configuration.  
      5.         var dojoConfig = {  
      6.             async: true,  
      7.             // This code registers the correct location of the "demo"  
      8.             // package so we can load Dojo from the CDN whilst still  
      9.             // being able to load local modules  
      10.             packages: [{  
      11.                 name: "demo",  
      12.                 location: location.pathname.replace(/\/[^/]*$/, '') + '/demo'  
      13.             }]  
      14.         };  
      15.     </script>  


      二、類的定義與繼承(http:///reference-guide/1.10/dojo/_base/declare.html)實(shí)例請(qǐng)參見官網(wǎng)



      cacheMap.js

      1. /**  
      2.  * Created by neil on 2015/8/27.  
      3.  */  
      4. define(["dojo/_base/declare",  
      5.     "esri/layers/ArcGISTiledMapServiceLayer",  
      6.     "esri/SpatialReference",  
      7.     "esri/geometry/Extent",  
      8.     "esri/layers/TileInfo"], function (declare, ArcGISTiledMapServiceLayer, SpatialReference, Extent, TileInfo) {  
      9.     return declare(ArcGISTiledMapServiceLayer, {  
      10.         constructor: function (baseUrl) {  
      11.             this.baseUrl=baseUrl;  
      12.         }  
      13.     });  
      14. });  

      dojo5.html

      1. <!DOCTYPE html>  
      2. <html>  
      3. <head lang="en">  
      4.     <meta charset="UTF-8">  
      5.     <title>這是測(cè)試瓦片地圖的一個(gè)類</title>  
      6.     <script>  
      7.         var dojoConfig = {  
      8.             async: true,  
      9.             packages: [{  
      10.                 name: "demo",  
      11.                 location: location.pathname.replace(/\/[^/]*$/, '') + '/demo'  
      12.             }]  
      13.         };  
      14.     </script>  
      15.     <script src="http://192.168.1.51/arcgis_js_api/library/3.14/3.14/init.js"></script>  
      16.     <script>  
      17.         require(["demo/cacheMap"], function (cacheMap) {  
      18.             var googleMapLayer = new cacheMap("baseUrl");  
      19.             greeting.innerHTML=googleMapLayer.baseUrl;  
      20.         });  
      21.     </script>  
      22. </head>  
      23. <body>  
      24. <h1 id="greeting">Hello</h1>  
      25. </body>  
      26. </html>  

      未完

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多