First, let’s look at the layout for this dijit. It consists of a border container with five regions(content panes): top, bottom, left, right and center, laid out in “Headline” pattern. For a detailed account on how to use the border container, read this blog post.
The top region is the the title bar for this dijit with icons, the whole left region is a button to navigate to the list of identified features, and the center region is the body of this dijit. The center region has a stack container that includes three pages (content panes) but shows only one at a time (see screenshots below). The first page contains a grid to display the list of identified features, the second page contains a grid to display the attribute fields, and the third page shows various options.
Easy to add
As a developer, you can use this dijit to easily add an identify tool to your map. All you need to do is pass a reference to the map when instantiating the dijit and it will let the users identify features on all the map services added as layers to the map. To use the dijit, just click the map to see the list of features identified at that location. Click a feature to see all the attribute field values associated with it. The dijit also has an “Options” panel where end users can select the map services and adjust the tolerance.
Try it live
That was quick and easy! But what if you want to customize it? For example, what if you want to
- Identify features on selected map services and layers within each map service
- Provide a user-friendly name for a layer
- Show user-friendly field aliases instead of field names
- Change the field that determines the title of the features
- Limit which attributes are shown
You can do all of the above by passing appropriate parameters to the dijit when instantiating it. Documentation for these parameters is available as part of the Code Gallery download, but you can take a quick look here. You can also change the look and feel by modifying the CSS file associated with the dijit.
Try it live
Finally, we recommend that you keep in mind the following points when creating your own dijit:
- Design the dijit in such a way that it is customizable and reusable as much as possible so that other developers in your organization can easily adapt it for their applications without diving too often into the code.
- Keep an eye out for functionality that can be spun off into separate modules and reused in other projects.
- Maintain user documentation for all your dijits and modules.
Writing your own widget
Lifecycle of a dijit