Reusable Accessible Mapping Platform

API Docs for: 3.0.0
Show:

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.

Methods

_hideLoadingImg

() private

Hides the loading image.

_initEventHandlers

(
  • map
)
private

Creates event handlers for the map control: click, mouse-over, load, extent change, and update events.

Parameters:

  • map Object

    A ESRI map object

_initListeners

(
  • map
)
private

Subscribe to external events (published using topic.publish) and react accordingly

Parameters:

_initRepublishers

(
  • map
)
private

Republishes map events to the outside using topic.publish

Parameters:

_initScale

(
  • event
)
private

Initialize Map Scale

Parameters:

_showLoadingImg

() private

Shows the loading image.

_updateScale

(
  • event
)
private

Update Map Scale when zoom level changes

Parameters:

activate

() private

Inherited from BaseTool but overwritten in src\js\RAMP\Tools\populationTool.js:139

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
)
private

Add a static, non-interactive Layer to the map

Parameters:

  • layer_type String

    A value which controls how the layer is going to be added to the map

  • layer_url String

    A URL pointing to a valid map service endpoint

  • layer_op Number

    A value between 0.0 and 1.0 which determines the transparency of the layer

checkBoundary

(
  • e
  • maxExtent
)
Esri/geometry/Extent

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/Extent

    the extent Object

  • maxExtent Esri/geometry/Extent

    the maximum extent

Returns:

Esri/geometry/Extent:

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
)
private

Compute an estimated amount of people in a specified polygon.

Parameters:

  • evtObj Object

    an object representing the event.

createExtent

(
  • extentConfig
  • sr
)
Esri/geometry/Extent private

Instantiates an extent from a JSON config object and spatial reference

Parameters:

Returns:

Esri/geometry/Extent:

An ESRI extent object based on the config data

deactivate

() private

Inherited from BaseTool but overwritten in src\js\RAMP\Tools\populationTool.js:151

Deactivates the Tool. This method is passed to the initToggle method and is triggered by the BaseTool logic.

displayOutput

() private

Inherited from BaseTool but overwritten in src\js\RAMP\Tools\populationTool.js:175

Displays the tool's output by calling BaseTool's displayOutput function.

displayTemplateOutput

(
  • templateData
  • [templateName]
)
chainable

Generates output to be injected into the tool's float given a template's name and data object.

Parameters:

  • templateData Object

    data to be put inside the specified template

  • [templateName] String optional

    template name to be completed with provided data; if not supplied, "toolOutputTemplate" property of the options object will be used

Returns:

this tool

getFeatureLayer

(
  • featureUrl
)
Esri/layer/FeatureLayer private

Return the feature layer corresponding to the given url.

Parameters:

  • featureUrl String

    the url of the feature layer

Returns:

Esri/layer/FeatureLayer:

feature layer

getVisibleFeatureLayers

() Array

Returns a list of feature layers that are currently visible on the map.

Returns:

Array:

an array of Esri/layer/FeatureLayer objects

init

() chainable

Initialize the population tool

initToggle

(
  • selector
  • d
  • [options]
)
chainable

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 JObject

    a target selector that serves as a toggle for the tool

  • d JObject

    a Deferred object to be resolved after tool initiates

  • [options] Object optional

    Additional options

    • [target] JObject optional

      Target where the tool's float should be appended to

    • [outputFloatTemplate] String optional

      Template name to generate the float container with

    • [outputFloatData] Object optional

      Data payload to be passed to the template engine when generate the float container

    • [workingLabelTemplate] String optional

      Template name to generate the busy label

    • [workingLabelData] Object optional

      Data payload to be passed to the template engine when generate the busy label

    • [activate] Function optional

      an activate function to be called when the toggle is clicked

    • [deactivate] Function optional

      a deactivate function to be called when the toggle is clicked

    • [defaultAction] Function optional

      Function to be executed when the float-default-button is clicked

Returns:

this tool

newPopup

(
  • popupAttr
)
private

Create a new PopupBase object from the settings provided.

Parameters:

Returns:

popup

outputTotalPopulation

(
  • evtObj
)
private

Display the calculated population on the map.

Parameters:

  • evtObj Object

    an object representing the event.

republish

(
  • name
)
private

Republish map events using topic.publish

Parameters:

setBoundingBoxVisibility

(
  • layerId
)
private

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 String

    the id of the layer whose bounding box visibility should be set

ui.init

() private

Initiates additional UI components of the Tool.

working

(
  • state
)
chainable

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 Boolean

    indicates the state of the tool: working, idle

Returns:

This tool

Properties

baseLayer

Esri/layers/ArcGISTiledMapServiceLayer private

The basemap layer

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"
 }

featureLayers

Array private

An Array of Esri/layer/FeatureLayer objects.

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

getConfigUrl

Object

Returns a URL that points to the application configuration (JSON format) if it's hosted on a web service. This is not required if the application has a JSON config file in the website's folder

getMap

Object

Return the map control object

getMaxExtent

Object

The maximum extent of the map control is allowed to go to

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

name

String

Name of the tool so AdvancedToolbar can distinguish between them.

Default: BaseTool

node

JObject

Node (button) the handle is attached too.

Default: null

options

Object private

Stored options passed to the BaseTool.

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>

spatialReference

Esri/SpatialReference private

The spatial reference of the map

template

Object

Stringified and parsed templates

Default: templates/tools_template.json

tooltip

JObject

Tooltip node that appears by the mouse cursor when tools is activated.

Default: $("#mainMap.map > .tooltip")

url

String private

The URL of the basemap that is on by default

wmsLayers

Array private

An Array of Esri/layer/WMSLayer objects.

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>

Events

ACTIVATE

Published whenever a Tool is activated.

Event Payload:

DEACTIVATE

Published whenever a Tool is deactivated.

Event Payload: