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
- _hideLoadingImg
- _initEventHandlers
- _initListeners
- _initRepublishers
- _initScale
- _showLoadingImg
- _updateScale
- _wrapFileCallInPromise
- addLayer
- AddStaticLayer
- adjustPaneWidth
- applyExtentDefaulting
- checkBoundary
- createGroups
- enhanceLayer
- finishExtentProjection
- getBoundingBoxMapping
- getFeatureLayer
- getLayerConfigWithId
- getLayerItem
- getLayerState
- getServiceURL
- getSymbolForFeature
- getVisibleFeatureLayers
- init
- initListeners
- initScrollListeners
- initTooltips
- loadStrings
- localProjectExtent
- makeFeatureLayer
- makeStaticLayer
- makeWmsLayer
- newPopup
- prepLayer
- projectConfigExtents
- projectExtent
- projectFullExtent
- projectMaxExtent
- removeLayer
- republish
- setBoundingBoxVisibility
- setButtonEvents
- setEachState
- setLayerOffScaleState
- setLayerOffScaleStates
- setLayerReorderingEvents
- setLayerState
- setLayerState
- setState
- ui.addLayerGroup
- ui.update
- zoomToLayerScale
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
_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.
_wrapFileCallInPromise
-
readMethod
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
Stringa string indicating the FileReader method to call
Returns:
a function which accepts a {File} object and returns a Promise
addLayer
-
layerType
-
layerConfig
-
initState
Add a provided layer to the layer selector.
AddStaticLayer
-
layer_type
-
layer_url
-
layer_op
Add a static, non-interactive Layer to the map
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
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
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.
finishExtentProjection
-
projectedMaxExtent
process the projected maximum extent, then alert app to continue loading the map. used as an asynchronous gate for the projection.
Parameters:
-
projectedMaxExtent
Arrayan 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:
A dictionary of String, Esri/layers/GraphicsLayer pairs.
getFeatureLayer
-
featureId
Return the feature layer corresponding to the given id.
Parameters:
-
featureId
Stringthe id of the feature layer
Returns:
feature layer
getLayerConfigWithId
-
id
Returns the feature layer config for the given id
Parameters:
-
id
Stringlayer id string
getLayerItem
-
layerId
Returns a LayerItem object with specified layerId.
Parameters:
-
layerId
Stringa layer id
getLayerState
-
layerId
Returns the state of the layer with the specified layer id.
Parameters:
-
layerId
Stringa layer id
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/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
Will project an extent to a desired spatial reference, using client side projection library. Avoids the need for Esri Geometry Service
Parameters:
-
extent
Esri/Extentextent to be projected
-
sr
Esri/SpatialReferenceEsri/SpatialReference to project to
Returns:
extent in the desired projection
makeFeatureLayer
-
layerConfig
-
userLayer
Create a new FeatureLayer object based on the config input
Parameters:
Returns:
feature layer object (unloaded)
makeStaticLayer
-
layerConfig
-
userLayer
Return the static layer corresponding to the given url.
Parameters:
Returns:
layer object of the appropriate type
makeWmsLayer
-
layerConfig
-
userLayer
Return the feature layer corresponding to the given url.
Parameters:
Returns:
WMS layer
newPopup
-
popupAttr
Create a new PopupBase object from the settings provided.
Parameters:
-
popupAttr
PopupBaseSettingsPopup settings
Returns:
popup
prepLayer
-
layer
-
config
-
userLayer
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
projectConfigExtents
()
initiate the projection of the config extents to basemap extents
projectExtent
-
extent
-
sr
-
callWhenDone
project an extent to a new spatial reference, if required when projection is finished, call another function and pass the result to it.
Parameters:
-
extent
Objectan extent object from the configuration
-
sr
Esri/SpatialReferenceEsri/SpatialReference to project to
-
callWhenDone
Functionfunction to call when extent is projected. expects geometry parameter
projectFullExtent
-
projectedDefaultExtent
process the projected default extent, begin projection of full extent. used as an asynchronous gate for the projection.
Parameters:
-
projectedDefaultExtent
Arrayan array containing the default extent object in the map's projection
projectMaxExtent
-
projectedFullExtent
process the projected full extent, begin projection of maximum extent. used as an asynchronous gate for the projection.
Parameters:
-
projectedFullExtent
Arrayan array containing the full extent object in the map's projection
removeLayer
-
layerType
-
layerId
Remove a layer from the layer selector.
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
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
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
setLayerOffScaleState
-
layerId
Checks if a specific layer has data that is not visible and sets the appropriate layer state.
Parameters:
-
layerId
Stringa layer id
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]
Set the state of the specified layer to the provided value.
setLayerState
-
layerId
-
layerState
-
[options]
Set the state of the specified layer to the provided value. Public hook to call internal setLayerState function.
setState
-
state
Toggle the state of Checkbox.
Parameters:
-
state
BooleanSpecifies the state of the checkbox: true, false
Returns:
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
Stringa 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"
}
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
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.