layer/layerRec/tileRecord.js

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