BookmarkLink Class
BookmarkLink class.
Steps for making the bookmark link update with an event
- Subscribe to the event of interest (e.g. map extent-change)
Create an object containing fields that will contain the necessary information for reconstructing the map to the same state. (e.g. for map extent-change, a useful object might be one that represents the current extent of the map:
{ xmin : 123, xmax : 456, ymin : 789, ymax : 000}).
IMPORTANT: the object must be serializable since it will be added to the URL and should serialize to a reasonable length String. If the fields contain non-primitives, e.g. array, object, one must manually serialize the field first. Also only use anonymous objects with custom fields, do not use class objects (e.g. use an anonymous { } object to store map extent instead of ESRI's map Esri/geometry/Extent object, since it will contain other fields and methods that will also be serialized).
Call updateURL, passing it a name (e.g. "newExtent") and the object (a name is required for efficiency, this way the URL will only need to serialize and update the given object instead of all objects).
Item Index
Methods
- _hideLoadingImg
- _initEventHandlers
- _initListeners
- _initRepublishers
- _initScale
- _showLoadingImg
- _updateScale
- addParameter
- AddStaticLayer
- checkBoundary
- createExtent
- getFeatureLayer
- getVisibleFeatureLayers
- init
- init!~YUIDOC_LINE~! homePage a string denoting the name of the homePage (e.g. usually "Default.aspx" or "index.html")
- newPopup
- republish
- setBoundingBoxVisibility
- subscribeAndUpdate
- toggleShortLinkMode
- updateURL
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.
addParameter
-
paramKey
-
paramObj
Update the parameter dictionary with the new values for the parameter. If paramObj is set to null, essentially removes the given paramKey from the URL.
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
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
getVisibleFeatureLayers
()
Array
Returns a list of feature layers that are currently visible on the map.
Returns:
an array of Esri/layer/FeatureLayer objects
init
()
private
Initiates additional UI components of the widget, setting listeners and other stuff.
init!~YUIDOC_LINE~! homePage a string denoting the name of the homePage (e.g. usually "Default.aspx" or "index.html")
()
Instantiates a BookmarkLink. Subscribes to all the events that causes the bookmark link to update (e.g. map extent change or feature layer visibility change).
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
subscribeAndUpdate
()
private
Subscribe to map state changes so the URL displayed can be changed accordingly. SUBSCRIBES TO: map "extent-change" Updates URL when map extent changes
EventManager.GUI.FULLSCREEN_CHANGE Updates URL when map goes into fullscreen mode
EventManager.GUI.TAB_SELECTED Updates URL when tabs are selected
EventManager.GUI.PANEL_CHANGE Updates URL when panel opens/closes
EventManager.BasemapSelector.BASEMAP_CHANGED Updates URL when basemap changed
- ================================================================
Subscribe to updates
To include more information into the query string, do not get the information directly from the object/module of interest, but rather make it publish an event with data to include and subscribe to this event here.
toggleShortLinkMode
-
value
Toggle the short/long link mode and change the label accordingly
Parameters:
-
value
Objecttrue - shortLinkMode; false - !shortlinkMore; undefined - toggle;
updateURL
()
private
Updates the link displayed in the textbox. This function should be called whenever one of the objects that are in the URL query is modified.
Properties
anchors
Object
private
A dictionary mapping names (String) to anchors (String) used at the end of the URL.
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.
boundingBoxVisibility
Object
private
A dictionary containing layer id (String) as key and bounding box visibility (boolean) as value
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
layerTransparency
Object
private
A dictionary with the layer id as key, and the transparency as value.
layerVisibility
Object
private
A dictionary containing layer id (String) as key and layer visibility (boolean) as value
maxExtent
Esri/geometry/Extent
private
The maximum extent of the map
parameters
Object
private
A dictionary mapping names (String) to query parameter (String) of the URL. The query parameter is what ends up in the url. The key can be any arbitrary name (best to name them to describe the query parameter).