注册 登录  
 加关注
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

快乐小屋

 
 
 

日志

 
 

进行arcgis js api开发需要了解的几个基本dojo语句  

2012-04-14 21:20:20|  分类: Javascript |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
Working with DojoE-mail This TopicPrintable VersionGive Us Feedback

Dojo is an open source toolkit that helps you write robust and efficient JavaScript code. JavaScript is a language that runs within the Web browser, and there are various flavors of Web browser that interpret the JavaScript in slightly different ways. Toolkits such as Dojo, YUI, Prototype, and many others are designed to abstract away the browser idiosyncrasies so that you don't have to learn them all and handle them in your code.

There are often several ways to code the same thing using JavaScript. Toolkits like Dojo provide functions you can use to do things in easier or more efficient ways. Using libraries from a toolkit can reduce the lines of code you write and make your JavaScript applications quicker and more stable.

What does it mean that the ArcGIS JavaScript API is built on top of Dojo?

The ESRI developers who created the ArcGIS JavaScript API used Dojo to simplify their development process and to ensure that the applications you build behave the same in different browsers. For example, the map zoom and panning animations use Dojo, as does the graphics layer.

Furthermore, the zoom level slider and info windows that you see in your JavaScript API maps are Dojo widgets (dijits). The slider dijit is provided with Dojo, and the info window is a custom dijit created by ESRI for the ArcGIS JavaScript API.

How much Dojo do I need to know in order to use the ArcGIS JavaScript API?

The amount of Dojo you use when you work with the ArcGIS JavaScript API is up to you, but at a minimum you'll need to use several common functions:

  • dojo.require: Similar to the <script> include tag on an HTML page. It imports resources into your JavaScript page.
    dojo.require("esri.map");

    For the JavaScript API, the most commonly imported resources are:

    ResourceUse for:
    esri.map Map, geometry, graphics, and symbols
    esri.layers.agsdynamic ArcGISDynamicMapServiceLayer
    esri.layers.agstiled ArcGISTiledMapServiceLayer
    esri.tasks.find Find task
    esri.tasks.geometry Geometry task
    esri.tasks.gp Geoprocessing task
    esri.tasks.identify Identify task
    esri.tasks.locator Locator task
    esri.tasks.query Query task
    esri.toolbars.draw Draw
    esri.toolbars.navigation Navigation
  • dojo.addOnLoad: Similar to <body onload="">. It registers an initializing block after the page has finished loading.
    dojo.addOnLoad(init);
  • dojo.connect: Similar to Element.addEventListener and Element.attachEvent JavaScript functions. It registers a listener to listen to specific events on an Object or element on the page and returns results from a function.
    dojo.connect(myMap,"onLoad", myLoadHandler);
  • dojo.byId: Similar to the document.getElementById(id) JavaScript function. The function searches and returns the first HTML element with the argument ID.
    dojo.byId("myInputField").value = myMap.id;

When writing your ArcGIS JavaScript applications, you can take advantage of the full Dojo toolkit, which includes buttons, grids, tree views, charts, and other widgets. The toolkit is divided into three parts:

Core - Essential functions like those listed above Dijit - Themeable widgets such as trees, menus, and buttons DojoX- Extension projects in various stages of development, such as graphics, grids, and charts

  评论这张
 
阅读(670)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018