layer/layerRec/imageRecord.js

  1. 'use strict';
  2. const layerRecord = require('./layerRecord.js')();
  3. const basicFC = require('./basicFC.js')();
  4. const placeholderFC = require('./placeholderFC.js')();
  5. const shared = require('./shared.js')();
  6. /**
  7. * @class ImageRecord
  8. */
  9. class ImageRecord extends layerRecord.LayerRecord {
  10. // NOTE: if we decide to support attributes from ImageServers,
  11. // we would extend from AttribRecord instead of LayerRecord
  12. // (and do a lot of testing!)
  13. /**
  14. * Create a layer record with the appropriate geoApi layer type. Layer config
  15. * should be fully merged with all layer options defined (i.e. this constructor
  16. * will not apply any defaults).
  17. * @param {Object} layerClass the ESRI api object for image server layers
  18. * @param {Object} apiRef object pointing to the geoApi. allows us to call other geoApi functions.
  19. * @param {Object} config layer config values
  20. * @param {Object} esriLayer an optional pre-constructed layer
  21. * @param {Function} epsgLookup an optional lookup function for EPSG codes (see geoService for signature)
  22. */
  23. constructor (layerClass, apiRef, config, esriLayer, epsgLookup) {
  24. super(layerClass, apiRef, config, esriLayer, epsgLookup);
  25. // handles placeholder symbol, possibly other things
  26. this._defaultFC = '0';
  27. this._featClasses['0'] = new placeholderFC.PlaceholderFC(this, this.name);
  28. }
  29. get layerType () { return shared.clientLayerType.ESRI_IMAGE; }
  30. /**
  31. * Triggers when the layer loads.
  32. *
  33. * @function onLoad
  34. */
  35. onLoad () {
  36. const loadPromises = super.onLoad();
  37. const fc = new basicFC.BasicFC(this, '0', this.config);
  38. this._featClasses['0'] = fc;
  39. loadPromises.push(fc.loadSymbology());
  40. Promise.all(loadPromises).then(() => {
  41. this._stateChange(shared.states.LOADED);
  42. });
  43. }
  44. }
  45. module.exports = () => ({
  46. ImageRecord
  47. });