Reusable Accessible Mapping Platform

API Docs for: 5.0.0
Show:

FilterManager Class

FilterManager class. Represents the legend next to the map and the controls to toggle each map layer's visibility and boundary box. The FilterManager also includes a attribute filter that allows the user to hide map features based on a attribute values

For a doc with diagrams on how this class works, please see http://ecollab.ncr.int.ec.gc.ca/projects/science-apps/priv/RAMP/RAMP%20AMD%20Filter%20Module.docx

Methods

_checkMaster

() private

Synchronizes the state of the master Checkbox with the state of the group. All group members checked -> master checked Any of the group members unchecked -> master unchecked

_emit

(
  • agency
)
private

Emits a TOGGLE event when the checkbox's state is changed.

Parameters:

  • agency String

    Specified the agency that toggled the Checkbox.

_getFeatures

(
  • fl
)
Object

Queries all map points on a given feature layer and returns their attributes

Parameters:

  • fl Object

    A feature layer to query

Returns:

Object:

An array of attributes from the designated feature layer

_getField

(
  • fl
  • field
)
Object

Grabs all distinct values of the given field from a featureLayer.

Parameters:

  • fl Object

    A feature layer to query

  • field String

    The field (or column) to query in the feature layer

Returns:

Object:

deferred A deferred object which will resolve to an array of unique values

_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:

_wrapFileCallInPromise

(
  • readMethod
)
Function private

Helper function for wrapping File API calls in Promise objects. Used for building a series of helpers which call different file read methods.

Parameters:

  • readMethod String

    a string indicating the FileReader method to call

Returns:

Function:

a function which accepts a {File} object and returns a Promise

addLayer

(
  • layerType
  • layerConfig
  • initState
)

Add a provided layer to the layer selector.

Parameters:

  • layerType String

    layer type - name of the layer group

  • layerConfig Object

    a layer config

  • initState String

    optional. the state to initialize in. Default value is LOADING

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

adjustPaneWidth

() private

Changes the width of the layers pane to accommodate for the scrollbar if it's needed.

applyExtentDefaulting

() private

Apply extent defaulting prior to URL overrides.

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

createGroups

() private

Sets UI status of a layer presentation (checkbox and eye) according to the user action: select / de-select a layer. publishes event "filterManager/box-visibility-toggled" every time a layer status changed. There should only be one eye and one global checkbox, but we say checkbox"es" because jquery returns a list and it's easier to write a function that takes a list of checkboxes than to write two functions, one to take a list and one to take an individual checkbox

enhanceLayer

(
  • layer
  • config
  • userLayer
)

Adds custom ramp properties to layer. Adds handlers to loading events.

Parameters:

  • layer Object

    layer to be prepped

  • config Object

    config object for the layer

  • userLayer Boolean

    optional. indicates if layer was added by a user. default value is false

finishExtentProjection

(
  • projectedMaxExtent
)
private

process the projected maximum extent, then alert app to continue loading the map. used as an asynchronous gate for the projection.

Parameters:

  • projectedMaxExtent Array

    an array containing the maximum extent object in the map's projection

getBoundingBoxMapping

() Object

Returns the mapping of feature layer ids to assocciated bounding box layers.

Returns:

Object:

A dictionary of String, Esri/layers/GraphicsLayer pairs.

getFeatureLayer

(
  • featureId
)
Esri/layers/FeatureLayer private

Return the feature layer corresponding to the given id.

Parameters:

  • featureId String

    the id of the feature layer

Returns:

Esri/layers/FeatureLayer:

feature layer

getLayerConfigWithId

(
  • id
)

Returns the feature layer config for the given id

Parameters:

getLayerItem

(
  • layerId
)
private

Returns a LayerItem object with specified layerId.

Parameters:

getLayerState

(
  • layerId
)
private

Returns the state of the layer with the specified layer id.

Parameters:

getServiceURL

(
  • rampService
  • mapID
  • language
)

This method builds a complete service URL callout for a map configuration. The URL is built using a base URL and map ID, and a language culture code.

Parameters:

  • rampService String

    The base URL for a web service that provide's valid map JSON configuration data

  • mapID Number

    a unique identifier for a group of map configuration

  • language String

    culture code either 'en' or 'fr'

getSymbolForFeature

(
  • feature
)
Icon

Given a feature object or a graphic object (or any object that has a getLayer method and an attributes field) return the object containing the image URL and legend text for that feature/graphic object.

Parameters:

Returns:

Icon:

The default icon used to represent the feature layer

getVisibleFeatureLayers

() Array

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

Returns:

Array:

an array of Esri/layers/FeatureLayer objects

init

()

Reads the application configuration and creates the legend and filter management widget

initListeners

() private

Initiates a listener to handle tab deselected event

initScrollListeners

() private

Adjusts filter style according to the scroll action on the layers.

initTooltips

() private

initialize a tooltip for each layer, using the layer name.

loadStrings

()

Updates some of the Strings on the HTML page using the config string resources

localProjectExtent

(
  • extent
  • sr
)
Esri/Extent private

Inherited from Map but overwritten in src\js\RAMP\Modules\map.js:420

Will project an extent to a desired spatial reference, using client side projection library. Avoids the need for Esri Geometry Service

Parameters:

Returns:

Esri/Extent:

extent in the desired projection

makeFeatureLayer

(
  • layerConfig
  • userLayer
)
Esri/layers/FeatureLayer

Create a new FeatureLayer object based on the config input

Parameters:

  • layerConfig Object

    config object for the layer to create

  • userLayer Boolean

    optional specifies if layer was added by a user

Returns:

Esri/layers/FeatureLayer:

feature layer object (unloaded)

makeStaticLayer

(
  • layerConfig
  • userLayer
)
Object private

Return the static layer corresponding to the given url.

Parameters:

  • layerConfig Object

    config object for the layer to create

  • userLayer Boolean

    optional specifies if layer was added by a user

Returns:

Object:

layer object of the appropriate type

makeWmsLayer

(
  • layerConfig
  • userLayer
)
Esri/layers/WMSLayer

Return the feature layer corresponding to the given url.

Parameters:

  • layerConfig Object

    config object for the layer to create

  • userLayer Boolean

    optional specifies if layer was added by a user

Returns:

Esri/layers/WMSLayer:

WMS layer

newPopup

(
  • popupAttr
)
private

Create a new PopupBase object from the settings provided.

Parameters:

Returns:

popup

prepLayer

(
  • layer
  • config
  • userLayer
)
private

Sets up loading event handlers and initializes the .ramp object of a layer Circular reference errors prevent us from calling LayerLoader directly from this module

Parameters:

  • layer Object

    layer to be prepped

  • config Object

    config object for the layer

  • userLayer Boolean

    optional. indicates if layer was added by a user. default value is false

projectConfigExtents

()

initiate the projection of the config extents to basemap extents

projectExtent

(
  • extent
  • sr
  • callWhenDone
)
private

project an extent to a new spatial reference, if required when projection is finished, call another function and pass the result to it.

Parameters:

projectFullExtent

(
  • projectedDefaultExtent
)
private

process the projected default extent, begin projection of full extent. used as an asynchronous gate for the projection.

Parameters:

  • projectedDefaultExtent Array

    an array containing the default extent object in the map's projection

projectMaxExtent

(
  • projectedFullExtent
)
private

process the projected full extent, begin projection of maximum extent. used as an asynchronous gate for the projection.

Parameters:

  • projectedFullExtent Array

    an array containing the full extent object in the map's projection

removeLayer

(
  • layerType
  • layerId
)

Remove a layer from the layer selector.

Parameters:

  • layerType String

    layer type - name of the layer group

  • layerId String

    layer id of layer to remove

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

setButtonEvents

() private

Sets event handlers for various controls that may be present in the layer items. All event handlers are set on the main list container and are independed of the individual layer items.

setEachState

(
  • fcn
)
chainable

Toggle all the checkboxes based on the return value of the given function.

Parameters:

  • fcn Function

    a function that takes a checkbox as an argument and returns true if the given checkbox should be toggled on, false if it should be toggled off

setLayerOffScaleState

(
  • layerId
)
private

Checks if a specific layer has data that is not visible and sets the appropriate layer state.

Parameters:

setLayerOffScaleStates

() private

Checks if any of the layers have data that is not visible and sets the appropriate layer state.

setLayerReorderingEvents

() private

Sets all the events to handle layer reordering with both mouse and keyboard.

setLayerState

(
  • layerId
  • layerState
  • [options]
)
private

Set the state of the specified layer to the provided value.

Parameters:

  • layerId String

    a layer id

  • layerState String

    a state to set the specified layer to

  • [options] Object optional

    additional options to be passed to the layerItem upon setting state

setLayerState

(
  • layerId
  • layerState
  • [options]
)

Set the state of the specified layer to the provided value. Public hook to call internal setLayerState function.

Parameters:

  • layerId String

    a layer id

  • layerState String

    a state to set the specified layer to

  • [options] Object optional

    additional options to be passed to the layerItem upon setting state

setState

(
  • state
)
Checkbox chainable

Inherited from CheckboxGroup but overwritten in src\js\RAMP\Utils\checkbox.js:219

Toggle the state of Checkbox.

Parameters:

  • state Boolean

    Specifies the state of the checkbox: true, false

Returns:

Checkbox:

Control object for chaining

ui.addLayerGroup

() private

Add the provided layer group node to the layer selector ui.

ui.update

() private

Updates certain UI aspects like layer settings panel (visibility sliders for now only), layer visibility and bounding box toggles, and layer sorting.

zoomToLayerScale

(
  • layerId
)

For a specified layer, zooms to the closest level that has some visible data.

Parameters:

  • layerId String

    a layer id to zoom to.

Properties

agency

Object private

An object specifying possible agencies that can affect the Checkbox.

Example:

 agency: {
      USER: "USER",
      CODE: "CODE"
  }

baseLayer

Esri/layers/ArcGISTiledMapServiceLayer private

The basemap layer

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/layers/GraphicsLayer pairs.

config

Object

The RAMP application config, it should be treated as read only by all modules other than globalStorage and bootstrapper

configServiceURL

String

Contains 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

cssClass

Object

Inherited from CheckboxGroup but overwritten in src\js\RAMP\Utils\checkbox.js:74

active, focus, and check CSS class to be applied to the Checkbox correspondingly.

Example:

 cssClass: {
     active: "active",
     focus: "focused",
     check: "checked"
 }

event

Object private

Inherited from CheckboxGroup but overwritten in src\js\RAMP\Utils\checkbox.js:285

Event names published by the Checkbox

Default: null

Example:

 {
     TOGGLE: "checkbox/toggle"
 }

featureLayers

Array private

An Array of Esri/layers/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

getMap

Object

Return the map control object

getMaxExtent

Object

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

id

String

Id of the Checkbox as specified by nodeIdAttr.

Default: null

InitExtent

Esri/geometry/Extent private

The initial extent of the map

label

Object

Inherited from CheckboxGroup but overwritten in src\js\RAMP\Utils\checkbox.js:93

check and uncheck label texts to be applied to the Checkbox labels.

Example:

 label: {
     check: "check",
     uncheck: "unchecked"
 }

labelNode

JObject private

Node of the input checkbox label.

Default: null

master

Object

Options for the master Checkbox.

Example:

 master: {
     node: null,
     checkbox: null,
     nodeIdAttr: null,

     cssClass: {
         active: "active",
         focus: "focused",
         check: "checked"
     },

     label: {
         check: "checked",
         uncheck: "unchecked"
     },

     onChange: function () { }
 }

maxExtent

Esri/geometry/Extent private

The maximum extent of the map

node

JObject

Node of the input checkbox originally supplied to the Checkbox.

Default: null

nodeIdAttr

String

Inherited from CheckboxGroup but overwritten in src\js\RAMP\Utils\checkbox.js:65

Name of the "data-*" attribute set on the checkbox node to be treated as the checkbox id.

Default: "id"

nodes

JArray

Inherited from CheckboxGroup but overwritten in src\js\RAMP\Utils\checkboxGroup.js:63

Nodes of the checkbox nodes originally supplied to the CheckboxGroup.

Default: []

onChnage

Function

Inherited from CheckboxGroup but overwritten in src\js\RAMP\Utils\checkbox.js:110

A function to be called when the state of the Checkbox changes.

Example:

 function () { }

plugins

Object

A registry of plugins for RAMP code to reference, these should be loaded and registered by bootstrapper.js

state

Boolean | String

Inherited from RAMP but overwritten in src\js\RAMP\Utils\checkbox.js:120

State of the Checkbox: true | false or INVALID

Default: null

url

String private

The URL of the first layer of the basemap that is on by default.

wmsLayers

Array private

An Array of Esri/layer/WMSLayer objects.

Events

FilterManager.BOX_VISIBILITY_TOGGLED

Provided by the UI module.

Defined in src\js\RAMP\Modules\eventManager.js:46

Published whenever the "box" button for a layer is clicked

Event Payload:

  • event Object
    • checked Boolean

      true if the "box" button is checked, false otherwise

    • node Object

      the input dom node that represents the checkbox

FilterManager.LAYER_TRANSPARENCY_CHANGED

Provided by the UI module.

Defined in src\js\RAMP\Modules\eventManager.js:35

Published each time the transparency of a layer is modified.

Event Payload:

  • event Object
    • layerId String

      the id of the layer

    • value Int

      the value of the slider

FilterManager.LAYER_VISIBILITY_TOGGLED

Provided by the UI module.

Defined in src\js\RAMP\Modules\eventManager.js:24

Published whenever the "eye" button for a layer is clicked

Event Payload:

  • event Object
    • checked Boolean

      true if the "eye" button is checked, false otherwise

    • node Object

      the input dom node that represents the checkbox

FilterManager.SELECTION_CHANGED

Provided by the UI module.

Defined in src\js\RAMP\Modules\eventManager.js:57

Published whenever the layer list is rearranged

Event Payload:

  • event Object
    • id String

      the layer Id

    • index Integer

      index of the layer that moved. index is relative to the control, not the layer stack in the map

FilterManager.TOGGLE_BOX_VISIBILITY [subscribed]

Provided by the UI module.

Defined in src\js\RAMP\Modules\eventManager.js:89

Tells the filter manager to toggle a layer on or off

Event Payload:

  • event Object
    • layerId String

      the name of the layer to toggle

    • state Boolean

      true if the layer should be visible, false otherwise

FilterManager.TOGGLE_LAYER_VISIBILITY [subscribed]

Provided by the UI module.

Defined in src\js\RAMP\Modules\eventManager.js:78

Tells the filter manager to toggle a layer on or off

Event Payload:

  • event Object
    • layerId String

      the name of the layer to toggle

    • state Boolean

      true if the layer should be visible, false otherwise

FilterManager.UI_COMPLETE

Provided by the UI module.

Defined in src\js\RAMP\Modules\eventManager.js:69

Published after the ui for the filter manager finishes initializing.

MASTER_TOGGLE

Published whenever the master Checkbox get toggled.

Event Payload:

  • event Object
    • checkbox Checkbox

      master Checkbox object that has been toggled

    • agency String

      Agency that toggled the Checkbox

MEMBER_TOGGLE

Published whenever a Checkbox get toggled.

Event Payload:

  • event Object
    • checkbox Checkbox

      Checkbox object that has been toggled

    • agency String

      Agency that toggled the Checkbox

TOGGLE

Inherited from CheckboxGroup but overwritten in src\js\RAMP\Utils\checkbox.js:298

Published whenever a Checkbox get toggled.

Event Payload:

  • event Object
    • checkbox Checkbox

      Checkbox object that has been toggled

    • agency String

      Agency that toggled the Checkbox