PopulationTool Class
PopulationTool.
Computes the total population of a selected area. When the user draws a polygon, the population will be displayed in the bottom right corner.
Item Index
Methods
- _hideLoadingImg
- _initEventHandlers
- _initListeners
- _initRepublishers
- _initScale
- _showLoadingImg
- _updateScale
- activate
- AddStaticLayer
- checkBoundary
- clearMap
- computeZonalStats
- createExtent
- deactivate
- displayOutput
- displayTemplateOutput
- getFeatureLayer
- getVisibleFeatureLayers
- init
- initToggle
- newPopup
- outputTotalPopulation
- republish
- setBoundingBoxVisibility
- ui.init
- working
Properties
Events
Methods
_hideLoadingImg
()
private
Hides the loading image.
_initEventHandlers
-
map
Creates event handlers for the map control: click, mouse-over, load, extent change, and update events.
Parameters:
-
map
ObjectA ESRI map object
_initListeners
-
map
Subscribe to external events (published using topic.publish) and react accordingly
Parameters:
-
map
Objectmap object
_initRepublishers
-
map
Republishes map events to the outside using topic.publish
Parameters:
-
map
Objectobject
_showLoadingImg
()
private
Shows the loading image.
activate
()
private
Activates the Tool. This method is passed to the initToggle
method and is triggered by the BaseTool logic.
AddStaticLayer
-
layer_type
-
layer_url
-
layer_op
Add a static, non-interactive Layer to the map
checkBoundary
-
e
-
maxExtent
Given an ESRI Extent Object, returns a new ESRI Extent Object that contains the extent adjusted according to this map's maximum extent
NOTE: this method is currently unused!
Parameters:
-
e
Esri/geometry/Extentthe extent Object
-
maxExtent
Esri/geometry/Extentthe maximum extent
Returns:
An adjusted extent, if the target extent is outside the boundary
clearMap
()
private
Clears the map. This method is passed to the initToggle
method as the defaultAction
to be triggered by the BaseTool logic when the float-default-button
is clicked.
computeZonalStats
-
evtObj
Compute an estimated amount of people in a specified polygon.
Parameters:
-
evtObj
Objectan object representing the event.
createExtent
-
extentConfig
-
sr
Instantiates an extent from a JSON config object and spatial reference
Parameters:
-
extentConfig
Objectthe JSON config object
-
sr
Esri/SpatialReference
Returns:
An ESRI extent object based on the config data
deactivate
()
private
Deactivates the Tool. This method is passed to the initToggle
method and is triggered by the BaseTool logic.
displayOutput
()
private
Displays the tool's output by calling BaseTool's displayOutput
function.
displayTemplateOutput
-
templateData
-
[templateName]
Generates output to be injected into the tool's float given a template's name and data object.
Parameters:
Returns:
this tool
getFeatureLayer
-
featureUrl
Return the feature layer corresponding to the given url.
Parameters:
-
featureUrl
Stringthe url of the feature layer
Returns:
feature layer
getVisibleFeatureLayers
()
Array
Returns a list of feature layers that are currently visible on the map.
Returns:
an array of Esri/layer/FeatureLayer objects
init
()
chainable
Initialize the population tool
initToggle
-
selector
-
d
-
[options]
Initializes the tool and sets up popup to handle activating/deactivating of the tool. Tools should call this function on init
,
unless they employ a different workflow and then need to handle all function activation/deactivation/working themselves.
Parameters:
-
selector
JObjecta target selector that serves as a toggle for the tool
-
d
JObjecta Deferred object to be resolved after tool initiates
-
[options]
Object optionalAdditional options
-
[target]
JObject optionalTarget where the tool's float should be appended to
-
[outputFloatTemplate]
String optionalTemplate name to generate the float container with
-
[outputFloatData]
Object optionalData payload to be passed to the template engine when generate the float container
-
[workingLabelTemplate]
String optionalTemplate name to generate the
busy
label -
[workingLabelData]
Object optionalData payload to be passed to the template engine when generate the
busy
label -
[activate]
Function optionalan activate function to be called when the toggle is clicked
-
[deactivate]
Function optionala deactivate function to be called when the toggle is clicked
-
[defaultAction]
Function optionalFunction to be executed when the
float-default-button
is clicked
-
Returns:
this tool
newPopup
-
popupAttr
Create a new PopupBase object from the settings provided.
Parameters:
-
popupAttr
PopupBaseSettingsPopup settings
Returns:
popup
outputTotalPopulation
-
evtObj
Display the calculated population on the map.
Parameters:
-
evtObj
Objectan object representing the event.
setBoundingBoxVisibility
-
layerId
Sets the visibility of the bounding box that belongs to the layer with the given layerId. Note: the layerId needs to be the ID of the featurelayer, not the ID of the actual bounding box layer.
Parameters:
-
layerId
Stringthe id of the layer whose bounding box visibility should be set
ui.init
()
private
Initiates additional UI components of the Tool.
working
-
state
Sets the tool into a specified state; if the tool is working
, a working
label is placed beside the cursor and injected into the tool output float.
Parameters:
-
state
Booleanindicates the state of the tool: working, idle
Returns:
This tool
Properties
boundingBoxLayers
Array of esri/layer/GraphicsLayer
A list GraphicsLayer that represent the extent bounding box of the feature layers. {[esr/layer/featurelayers]} featureLayers A list of feature layers found in the application config {[esri/layer/graphiclayer]} An array of graphic layers to add to the map
boundingBoxMapping
Object
private
Maps the id of a graphic layer to the GraphicsLayer Object that represents its extent bounding box. A dictionary of String, Esri/layer/GraphicsLayer pairs.
event
Object
Event names published by the BaseTool
Default: null
Example:
{
ACTIVATE: "basetool-activate",
DEACTIVATE: "basetool-deactivate"
}
featureLayerStartIndex
Integer
private
The map not only contains feature layers, but also other layers such as the basemap layer, highlight layer, bounding box layer, etc. This variable is used to store the starting index of the feature layers in the map.
fullExtent
Esri/geometry/Extent
private
Used for full extent in nav widget
handle
JObject
Handle (popup handle) that triggers opening/closing of the tool.
Default: null
InitExtent
Esri/geometry/Extent
private
The initial extent of the map
maxExtent
Esri/geometry/Extent
private
The maximum extent of the map
node
JObject
Node (button) the handle is attached too.
Default: null
outputFloat
JObject
Node representing the tool output float container.
Default: templates/tools_template.json:base_tool_float
Example:
<div class='advanced-output-section-container'>
<div class='advanced-output-section'>
<section class='float-content'></section>
<button class='button button-none float-default-button' >
<i class='fa fa-trash-o'></i><span class='on-right'>{%= o.clearMapButton %}</span>
</button>
<div class='clear'></div>
</div>
</div>
tooltip
JObject
Tooltip node that appears by the mouse cursor when tools is activated.
Default: $("#mainMap.map > .tooltip")
workingLabel
String
Template string representing working
label shown when the tool is in busy
state.
Default: templates/tools_template.json:working_label
Example:
<span class='tool-tooltip'><i class='fa fa-cog fa-spin'></i>{%= o.workingLabel %}</span>