This article was previously published at GeoChalkboard in the form of a two-part article, and has been reproduced here with permission.
What is Dojo?
What does it do?
Dojo is perhaps best known for the HTML user interface components, called Dijits, which you can plug into your application. You can see some examples of these components by reviewing the Dojo Feature Explorer provided by DojoCampus.org. This alone would be good reason to use Dojo, but this toolkit provides so much more. In addition, to the user components Dojo also provides the following:
- Fixes browser incompatibilities and memory leaks (no more browser dependent code)
- Normalizes the browser event system across browsers
- DOM utilities
- Build system that divides your code into small, manageable chunks for development and a packaging system for optimal download performance
- Internationalization, localization, and accessibility
- Support for asynchronous programming
- Remote scripting with XHR, script, and iframe
- Drivers for accessing data in JSON, XML, CSV, and other formats including web services such as Flickr and Picasa
Three Projects (Dojo, Dijits, DojoX)
What we call Dojo is actually three separate projects: Dojo, Dijits, and DojoX.
Dojo core is the foundation for all three projects and handles browser normalization, fixes browser incompatibilities, allows DOM querying, remote scripting, drag and drop, data store API, localization and internationalization, Firebug integration, cookie handling, accessibility, and much more.
Dijit includes the Dojo framework along with roughly 40 HTML user interface widgets including buttons, text boxes, grids, tree views charts, color pickets and many others. Tundra is the default CSS theme for Dijit and is designed to blend into existing color palettes and design. An additional theme, Soria, is available as well and you can certainly build your own if neither the Tundra or Soria themes fit your needs.
DojoX are Dojo extensions and includes projects such as the grid widget, a graphics library, charting, image handling and more. These often include some very sophisticated projects which are not necessarily as stable as what you’ll find in Dojo or Dijit.
ESRI and Dojo
In fact, the ESRI zoom slider was built with the Vertical Slider Dijit.
In coming posts we’ll take a look at how you can integrate a number of other dijits into your web applications.
Using Dojo with Google Maps API
Your other options for downloading Dojo to your local environment include:
- References in the head section to:
- Dojo style sheet you intend to use
- Set the class for the body tag to the Dojo style sheet you have selected
- Add dojo. Require statements for the ArcGIS Server and Dojo resources you intend to use
A reference to the style sheet provided by Dojo is provided mainly to control the look and feel of the graphic elements in your map as well as any user interface dijits that you add to your application. This is accomplished by adding the following line of code in the head section of your application.
Step 2: Set the Class of the Map div Tag
Next, you’ll need to set the class of the map to match the theme of the style sheet that you referenced in Step 1. Notice in the code example below that we are referencing the “tundra” theme. If you had referenced the “soria”, “nihilo”, or your own custom style sheet you’d reference this theme here instead of “tundra”.
Step 3: Add dojo.require() Statements
To use any of these resources in your application you will need to import them into your application with dojo.require() . For example, the two lines of code that you see below will import functionality related to maps, geometry, graphics and symbols (“esri.map”) as well as geoprocessing functionality (“esri.geoprocessing”).
The dojo.require() method can also be used to import various Dojo dijits and other functionality provided by Dojo core.
Each of these “resources” are really small code modules and act much the same as “include” or “import” statements in other languages. Each dojo.require( ) statement is placed inside a script tag in the head section of your application.
This article was written by Eric Pimpler at GeoSpatial Training Services. Geospatial Training Services provide a
range of geoweb courses.