Reusable Accessible Mapping Platform

API Docs for: 5.3.2
Show:

LayerLoader Class

Layer Loader class.

Handles the asynchronous loading of map layers (excluding basemaps) This includes dealing with errors, and raising appropriate events when the layer loads

Imports RAMP Modules:

EventManager FeatureClickHandler FilterManager GlobalStorage LayerItem Map MapClickHandler Ramp Util

Methods

_loadLayer

(
  • layer
  • reloadIndex
)
private

This function initiates the loading of an ESRI layer object to the map. Will add it to the map in the appropriate spot, wire up event handlers, and generate any bounding box layers Note: a point of confusion. The layer objects "load" event may have already finished by the time this function is called. This means the object's constructor has initialized itself with the layers data source. This functions is not event triggered to guarantee the order in which things are added.

Parameters:

  • layer Object

    an instantiated, unloaded ESRI layer object

  • reloadIndex Integer

    Optional. If reloading a layer, supply the index it should reside at. Do not set for new layers

areaSearch

(
  • filters
  • defResult
)
private

Provided by the GeoSearch module.

Defined in src/js/RAMP/Modules/geoSearch.js:414

Will trigger an area search and package the results

Parameters:

  • filters Object

    search filters, particarly lonlat and optional radius

  • defResult Object

    a Deferred supplied by the caller. areaSearch will resolve or reject it

executeSearch

(
  • params
)
Object private

Provided by the GeoSearch module.

Defined in src/js/RAMP/Modules/geoSearch.js:274

Will execute a specific search against the geoname service

Parameters:

  • params Object

    values to use in the search

Returns:

Object:

promise of results

fsaSearch

(
  • fsa
)
Object private

Provided by the GeoSearch module.

Defined in src/js/RAMP/Modules/geoSearch.js:226

Will search for an FSA Promise delivers centroid lat long if FSA is found

Parameters:

Returns:

Object:

promise of results

generalSearch

(
  • name
  • filters
  • defResult
)
private

Provided by the GeoSearch module.

Defined in src/js/RAMP/Modules/geoSearch.js:377

Will trigger an basic name search, apply filters, and package the results

Parameters:

  • name String

    string to search on

  • filters Object

    search filters, particarly lonlat and optional radius

  • defResult Object

    a Deferred supplied by the caller. areaSearch will resolve or reject it

geoSearch

(
  • input
  • filters
)
Object private

Provided by the GeoSearch module.

Defined in src/js/RAMP/Modules/geoSearch.js:447

Will search on user input string. Public endpoint for searches, will orchestrate the appropriate search calls. Accepts the following filter properties

  • radius: size of search radius search in km. default 10. only used with lat/long or FSA searches
  • prov: province code (numeric, e.g. 35, not 'ON')
  • concise: concise type code
  • showAll: show all results or clip to first 10. default false
  • extent: extent of search area in lat/long [xmin, ymin, xmax, ymax]. caller will project from basemap to latlong. reasoning: caller can project once then cache until extent changes

Result object can have the following properties

  • status: status of the search. values are list, none, hide. list means results are present. none means no results. hide means nothing should be shown (e.g. 1 char search string, bad postal code)
  • defItem: a lonlat array of the default result to zoom to if a person hits enter. for FSA, it is FSA centroid; for lat/long, it is the lat/long point; otherwise it is the first result
  • list: array of search results
    • name: name of the result
    • location: general area where the result is situated
    • province: province code where the result is found (numeric, e.g. 35, not 'ON')
    • lonlat: co-ordinate where the result is located. array of [longitude, latitude]
    • type: concise type code for the result

Parameters:

  • input String

    search item user has entered

  • filters Object

    any filters provided from the UI

Returns:

Object:

promise of results

getConciseList

() Array private

Provided by the GeoSearch module.

Defined in src/js/RAMP/Modules/geoSearch.js:122

Returns a list of concise names and codes for the UI dropdown combo

Returns:

Array:

a list of concise names and codes

getProvCode

(
  • prov
)
String private

Provided by the GeoSearch module.

Defined in src/js/RAMP/Modules/geoSearch.js:72

Convert a provice name to province code

Parameters:

Returns:

String:

province code. undefined if no match

getProvList

() Array private

Provided by the GeoSearch module.

Defined in src/js/RAMP/Modules/geoSearch.js:104

Returns a list of provinces and codes for the UI dropdown combo

Returns:

Array:

a list of province names and codes

init

()

Initializes properties. Set up event listeners

isInExtent

(
  • point
  • extent
)
Boolean private

Provided by the GeoSearch module.

Defined in src/js/RAMP/Modules/geoSearch.js:157

Will determine if a point is inside an extent

Parameters:

  • point Array

    co-ordinates in [lon, lat] format

  • extent Array

    co-ordinates in [lon_min, lat_min, lon_max, lat_max] format

Returns:

Boolean:

tells if the point is inside the extent

isLatLong

(
  • value
)
Boolean private

Provided by the GeoSearch module.

Defined in src/js/RAMP/Modules/geoSearch.js:140

Will determine if a value is a valid number for a lat/long co-ordinate

Parameters:

Returns:

Boolean:

tells if value is valid lat/long

isLatLong

() private

Provided by the GeoSearch module.

Defined in src/js/RAMP/Modules/geoSearch.js:541

Will initialize the module. Download provice keys & info. Download concise types keys & info.

isProvince

(
  • value
)
Boolean private

Provided by the GeoSearch module.

Defined in src/js/RAMP/Modules/geoSearch.js:56

Will determine if a value is a valid province identifier (en/fr name or 2-letter abbr)

Parameters:

Returns:

Boolean:

tells if value is valid province identifier

loadLayer

(
  • layer
  • reloadIndex
)

Public endpoint to initiate the loading of an ESRI layer object to the map.

Parameters:

  • layer Object

    an instantiated, unloaded ESRI layer object

  • reloadIndex Integer

    Optional. If reloading a layer, supply the index it should reside at. Do not set for new layers

onLayerError

(
  • layerId
)
private

Will remove a layer from the map, and adjust counts.

Parameters:

  • layerId String

    config id of the layer

onLayerError

(
  • evt
)

Deals with a layer that had an error when it tried to load.

Parameters:

onLayerLoaded

(
  • evt
)

Reacts when a layer has loaded successfully. This means the site has shaken hands with the layer and it seems ok. This does not mean data has been downloaded

Parameters:

onLayerRemove

(
  • evt
)

Reacts to a request for a layer to be removed. Usually the case when a layer errors and the user clicks remove.

Parameters:

onLayerRemove

(
  • evt
)

Reacts to a request for a layer to be reloaded. Usually the case when a layer errors and user wants to try again

Parameters:

onLayerUpdateEnd

(
  • evt
)

Reacts when a layer has updated successfully. This means the layer has pulled its data and displayed it.

Parameters:

onLayerUpdateStart

(
  • evt
)

Reacts when a layer begins to update. This happens when a feature layer starts to download its data. Data download doesn't start until points are made visible. It also happens when a WMS requests a new picture.

Parameters:

parseInput

(
  • input
)
Object private

Provided by the GeoSearch module.

Defined in src/js/RAMP/Modules/geoSearch.js:170

Will examine the user search string. Returns any special type and related data Valid types are: none, fsa, lonlat, prov

Parameters:

  • input String

    user search string

Returns:

Object:

result of parse. has .type (string) and .data (object) properties

updateLayerSelectorState

(
  • layerId
  • newState
  • abortIfError
  • [options]
)
private

Will set a layerId's layer selector state to a new state.

Parameters:

  • layerId String

    config id of the layer

  • newState String

    the state to set the layer to in the layer selector

  • abortIfError Boolean

    if true, don't update state if current state is an error state

  • [options] Object optional

    additional options for layer item (mostly error messages in this case)

Events

LayerLoader.LAYER_ADDED

Provided by the UI module.

Defined in src/js/RAMP/Modules/eventManager.js:409

Indicates that a map layer has been added to the layer selector

Event Payload:

  • event Object
    • layer Object

      layer object that has been added

LayerLoader.LAYER_ERROR

Provided by the UI module.

Defined in src/js/RAMP/Modules/eventManager.js:464

Indicates that a map layer has errored

Event Payload:

  • event Object
    • layer Object

      ESRI layer object that has errored

    • error Object

      the error object

LayerLoader.LAYER_LOADED

Provided by the UI module.

Defined in src/js/RAMP/Modules/eventManager.js:398

Indicates that a map layer has loaded. This means the constructor initialized and shook hands with it's data source

Event Payload:

  • event Object
    • layer Object

      ESRI layer object that has loaded

LayerLoader.LAYER_UPDATED

Provided by the UI module.

Defined in src/js/RAMP/Modules/eventManager.js:420

Indicates that a map layer has updated. This means the data it is showing is visible and up-to-date

Event Payload:

  • event Object
    • layer Object

      ESRI layer object that has updated

LayerLoader.LAYER_UPDATING

Provided by the UI module.

Defined in src/js/RAMP/Modules/eventManager.js:431

Indicates that a map layer has started updating. This means it is getting data from its source

Event Payload:

  • event Object
    • layer Object

      ESRI layer object that is updating

LayerLoader.RELOAD_LAYER

Provided by the UI module.

Defined in src/js/RAMP/Modules/eventManager.js:453

Indicates that a map layer should be removed from the map

Event Payload:

LayerLoader.REMOVE_LAYER

Provided by the UI module.

Defined in src/js/RAMP/Modules/eventManager.js:442

Indicates that a map layer should be removed from the map

Event Payload: