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
Item Index
Methods
- _checkMaster
- _emit
- _getFeatures
- _getField
- _getSymbolConfig
- _hideLoadingImg
- _initEventHandlers
- _initListeners
- _initRepublishers
- _initScale
- _showLoadingImg
- _updateScale
- AddStaticLayer
- adjustExpandAllButtonState
- adjustPaneWidth
- checkBoundary
- createExtent
- getFeatureLayer
- getLayerConfig
- getServiceURL
- getSymbolForFeature
- getVisibleFeatureLayers
- init
- initListeners
- initScrollListeners
- initTooltips
- loadStrings
- newPopup
- republish
- setBoundingBoxVisibility
- setButtonEvents
- setCheckboxEvents
- setEachState
- setLayerReorderingEvents
- setState
Properties
Events
- FilterManager.BOX_VISIBILITY_TOGGLED
- FilterManager.LAYER_TRANSPARENCY_CHANGED
- FilterManager.LAYER_VISIBILITY_TOGGLED
- FilterManager.SELECTION_CHANGED
- FilterManager.TOGGLE_BOX_VISIBILITY [subscribed]
- FilterManager.TOGGLE_LAYER_VISIBILITY [subscribed]
- FilterManager.UI_COMPLETE
- MASTER_TOGGLE
- MEMBER_TOGGLE
- TOGGLE
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
Emits a TOGGLE
event when the checkbox's state is changed.
Parameters:
-
agency
StringSpecified the agency that toggled the Checkbox.
_getFeatures
-
fl
Queries all map points on a given feature layer and returns their attributes
Parameters:
-
fl
ObjectA feature layer to query
Returns:
An array of attributes from the designated feature layer
_getField
-
fl
-
field
Grabs all distinct values of the given field from a featureLayer.
Parameters:
Returns:
deferred A deferred object which will resolve to an array of unique values
_getSymbolConfig
-
layerUrl
-
wmsName
Gets the defined symbology from a layer's web service
Parameters:
Returns:
The defined symbology from the layer definition
_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.
AddStaticLayer
-
layer_type
-
layer_url
-
layer_op
Add a static, non-interactive Layer to the map
adjustExpandAllButtonState
()
private
Changes the state of the expand all control if all the nodes are expanded.
adjustPaneWidth
()
private
Changes the width of the layers pane to accommodate for the scrollbar if it's needed.
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
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
getFeatureLayer
-
featureUrl
Return the feature layer corresponding to the given url.
Parameters:
-
featureUrl
Stringthe url of the feature layer
Returns:
feature layer
getLayerConfig
-
url
-
wmsName
Returns the feature layer config for the given url
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.
getSymbolForFeature
-
feature
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:
-
feature
Object
Returns:
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:
an array of Esri/layer/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
newPopup
-
popupAttr
Create a new PopupBase object from the settings provided.
Parameters:
-
popupAttr
PopupBaseSettingsPopup settings
Returns:
popup
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
setButtonEvents
()
private
Adjusts UI layout according to a layer event.
setCheckboxEvents
()
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
setEachState
-
fcn
Toggle all the checkboxes based on the return value of the given function.
Parameters:
-
fcn
Functiona 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
setLayerReorderingEvents
()
private
Sets all the events to handle layer reordering with both mouse and keyboard.
Properties
agency
Object
private
An object specifying possible agencies that can affect the Checkbox.
Example:
agency: {
USER: "USER",
CODE: "CODE"
}
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.
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
active
, focus
, and check
CSS class to be applied to the Checkbox correspondingly.
Example:
cssClass: {
active: "active",
focus: "focused",
check: "checked"
}
event
Object
private
Event names published by the Checkbox
Default: null
Example:
{
TOGGLE: "checkbox/toggle"
}
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
InitExtent
Esri/geometry/Extent
private
The initial extent of the map
label
Object
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
Name of the "data-*" attribute set on the checkbox node to be treated as the checkbox id.
Default: "id"
nodes
JArray
Nodes of the checkbox nodes originally supplied to the CheckboxGroup.
Default: []
onChnage
Function
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
Events
FilterManager.BOX_VISIBILITY_TOGGLED
Published whenever the "box" button for a layer is clicked
FilterManager.LAYER_TRANSPARENCY_CHANGED
Published each time the transparency of a layer is modified.
FilterManager.LAYER_VISIBILITY_TOGGLED
Published whenever the "eye" button for a layer is clicked
FilterManager.SELECTION_CHANGED
Published whenever the layer list is rearranged
FilterManager.TOGGLE_BOX_VISIBILITY [subscribed]
Tells the filter manager to toggle a layer on or off
FilterManager.TOGGLE_LAYER_VISIBILITY [subscribed]
Tells the filter manager to toggle a layer on or off
FilterManager.UI_COMPLETE
Published after the ui for the filter manager finishes initializing.
MASTER_TOGGLE
Published whenever the master Checkbox get toggled.
MEMBER_TOGGLE
Published whenever a Checkbox get toggled.