In this topic
  1. _Tool

This is an archive related to a previous version of Esri Maps for SharePoint. If you need the current version go to http://doc.arcgis.com/en/maps-for-sharepoint/.

Tool

As a developer, you may want to add functionality to Esri Maps for SharePoint by creating custom tools. Tools are executed through user interaction. They can be added as buttons, tools, or menu items to tool containers in the map.

Tool class OMD

_Tool

This is the base class for all tools. Extend this class to create a custom tool.

Description

Tools are extensions that are executed through user interaction; they provide a way to expose logic in the map that should be initiated by the user, as opposed to behaviors, which react to events. Tools can be added as buttons or tools on toolbars and menus in the Esri Map app. The following code sample illustrates a custom tool that records the extents of the map.

define([
    "dojo/_base/declare",
    "esriMaps/extensions/tools/_Tool",
], function(declare, _Tool) {
 
return declare(_Tool, {
 
    label: "My Custom Tool",
    description: "A Tool that logs the Map extent",  
    execute: function() { 
        window.console.log (this.app.mapManager.map.extent);
   },
 
   ...
 
 });
});

_Tool implements the following three dojo mixins:

  • dojo/Stateful
  • dojo/Evented
  • dojo/Deferred

Properties

NameTypeSummary

description

String

Description of the tool.

enabled

Boolean

Indicates whether the tool is enabled. Use this property to define the availability of the tool. If the tool relies on the presence of a particular layer or particular state of the map, then use this property to disable the tool until the conditions are met. The default value is true.

iconClass

String

CSS class name. Specifies the CSS class name to use when the tool is placed in a tool container that shows icons.

label

String

Label for the tool.

showTooltip

Boolean

Defines the visibility of the ToolTip. Specifies whether the tool should display the ToolTip. The default value is true.

tooltip

String

The message displayed in the ToolTip. Specifies the message displayed as a ToolTip when the user hovers over the tool. If no ToolTip is set, accessing the ToolTip via tool.get('tooltip') defaults to the tool's description, or to the label if no description is set.

visible

Boolean

Defines the tool's visibility. Specifies whether a tool is visible. The default value is true.

Methods

NameReturn typeSummary

destroy()

Nothing

Destroys the instance of the extension.

execute()

Nothing

Called when the tool is clicked. If the intended result of clicking the tool is to display a widget or a custom UI, call the code to show the widget in this function to implement the desired functionality.

initialize(app)

Nothing

Initializes the extension.

toJson

Object

Returns the properties of the tool as a JSON string. If there are properties or settings that need to be saved, return them as a JSON. When the app is saved, the app calls each of the object's toJson method to get the properties that need to be saved.

Events

On EventEvent PropertiesDescription

onError

Use to report and log errors encountered in an extension.