diff --git a/src/js/collections/maps/AssetCategories.js b/src/js/collections/maps/AssetCategories.js index 641a6f481..4625eff8e 100644 --- a/src/js/collections/maps/AssetCategories.js +++ b/src/js/collections/maps/AssetCategories.js @@ -5,7 +5,7 @@ define([ "models/maps/AssetCategory", "models/maps/Map", "collections/maps/MapAssets", -], function (Backbone, AssetCategory, MapModel, MapAssets) { +], (Backbone, AssetCategory, MapModel, MapAssets) => { /** * @classdesc AssetCategories collection is a group of AssetCategory models - models * that provide the information required to render geo-spatial data in categories, @@ -53,9 +53,7 @@ define([ * @returns {MapAssets[]} A list of MapAssets collections. */ getMapAssets() { - return this.map((assetCategory) => { - return assetCategory.get("mapAssets"); - }); + return this.map((assetCategory) => assetCategory.get("mapAssets")); }, }, ); diff --git a/src/js/collections/maps/viewfinder/ZoomPresets.js b/src/js/collections/maps/viewfinder/ZoomPresets.js index 0be1c3c72..f992eec2b 100644 --- a/src/js/collections/maps/viewfinder/ZoomPresets.js +++ b/src/js/collections/maps/viewfinder/ZoomPresets.js @@ -4,7 +4,16 @@ define([ "underscore", "backbone", "models/maps/viewfinder/ZoomPresetModel", -], function (_, Backbone, ZoomPresetModel) { +], (_, Backbone, ZoomPresetModel) => { + /** + * Determine if array is empty. + * @param {Array} a The array in question. + * @returns {boolean} Whether the array is empty. + */ + function isNonEmptyArray(a) { + return a && a.length && Array.isArray(a); + } + /** * @class ZoomPresets * @classdesc A ZoomPresets collection is a group of ZoomPresetModel models @@ -12,9 +21,9 @@ define([ * selects. * @class ZoomPresets * @classcategory Collections/Maps - * @extends Backbone.Collection + * @augments Backbone.Collection * @since 2.29.0 - * @constructor + * @class */ const ZoomPresets = Backbone.Collection.extend( /** @lends ZoomPresets.prototype */ { @@ -22,17 +31,27 @@ define([ model: ZoomPresetModel, /** - * @param {Object[]} zoomPresets The raw list of objects that represent + * @typedef {object} ZoomPresetsParseOptions + * @property {object} zoomPresets The raw list of objects that represent * the zoom presets, to be converted into ZoomPresetModels. - * @param {MapAsset[]} allLayers All of the layers available for display + * @property {MapAsset[]} allLayers All of the layers available for display * in the map. */ + + /** + * Parse values and return a list of models for creating a + * Backbone.Collection. + * @param {ZoomPresetsParseOptions} object Values to be parsed into the + * Backbone.Collection. + * @returns {ZoomPresets} A collection of models representative of the + * values passed in. + */ parse({ zoomPresetObjects, allLayers }) { if (isNonEmptyArray(zoomPresetObjects)) { const zoomPresets = zoomPresetObjects.map((zoomPresetObj) => { const enabledLayerIds = []; const enabledLayerLabels = []; - for (const layer of allLayers.models) { + allLayers.models.forEach(layer => { if ( zoomPresetObj.layerIds?.find( (id) => id === layer.get("layerId"), @@ -41,7 +60,7 @@ define([ enabledLayerIds.push(layer.get("layerId")); enabledLayerLabels.push(layer.get("label")); } - } + }); return new ZoomPresetModel( { @@ -67,9 +86,5 @@ define([ }, ); - function isNonEmptyArray(a) { - return a && a.length && Array.isArray(a); - } - return ZoomPresets; }); diff --git a/src/js/models/maps/Map.js b/src/js/models/maps/Map.js index 0df6f2f38..094065e98 100644 --- a/src/js/models/maps/Map.js +++ b/src/js/models/maps/Map.js @@ -9,7 +9,7 @@ define([ "collections/maps/AssetCategories", "models/maps/GeoPoint", "collections/maps/viewfinder/ZoomPresets", -], function ( +], ( $, _, Backbone, @@ -18,7 +18,16 @@ define([ AssetCategories, GeoPoint, ZoomPresets, -) { +) => { + /** + * Determine if array is empty. + * @param {Array} a The array in question. + * @returns {boolean} Whether the array is empty. + */ + function isNonEmptyArray(a) { + return a && a.length && Array.isArray(a); + } + /** * @class MapModel * @classdesc The Map Model contains all of the settings and options for a @@ -26,16 +35,16 @@ define([ * @classcategory Models/Maps * @name MapModel * @since 2.18.0 - * @extends Backbone.Model + * @augments Backbone.Model */ - var MapModel = Backbone.Model.extend( + const MapModel = Backbone.Model.extend( /** @lends MapModel.prototype */ { /** * Configuration options for a {@link MapModel} that control the * appearance of the map, the data/imagery displayed, and which UI * components are rendered. A MapConfig object can be used when * initializing a Map model, e.g. `new Map(myMapConfig)` - * @namespace {Object} MapConfig + * @namespace {object} MapConfig * @property {MapConfig#CameraPosition} [homePosition] - A set of * coordinates that give the (3D) starting point of the Viewer. This * position is also where the "home" button in the Cesium widget will @@ -134,7 +143,7 @@ define([ /** * Coordinates that describe a camera position for Cesium. Requires at * least a longitude and latitude. - * @typedef {Object} MapConfig#CameraPosition + * @typedef {object} MapConfig#CameraPosition * @property {number} longitude - Longitude of the central home point * @property {number} latitude - Latitude of the central home point * @property {number} [height] - Height above sea level (meters) @@ -227,7 +236,7 @@ define([ * UI appears within the ViewfinderView. * UI appears within the ViewfinderView. */ - defaults: function () { + defaults() { return { homePosition: { longitude: -65, @@ -266,13 +275,9 @@ define([ * for the map. If any config option is not specified, the default will be * used instead (see {@link MapModel#defaults}). */ - initialize: function (config) { + initialize(config) { try { if (config && config instanceof Object) { - function isNonEmptyArray(a) { - return a && a.length && Array.isArray(a); - } - if (isNonEmptyArray(config.layerCategories)) { const assetCategories = new AssetCategories( config.layerCategories, @@ -316,7 +321,7 @@ define([ * @returns {MapInteraction} The new interactions model. * @since 2.27.0 */ - setUpInteractions: function () { + setUpInteractions() { const interactions = new Interactions({ mapModel: this, }); @@ -330,7 +335,7 @@ define([ * @param {Feature[]} features - An array of Feature models to select. * since 2.28.0 */ - selectFeatures: function (features) { + selectFeatures(features) { this.get("interactions")?.selectFeatures(features); }, @@ -339,7 +344,7 @@ define([ * @returns {Features} The selected Feature collection. * @since 2.27.0 */ - getSelectedFeatures: function () { + getSelectedFeatures() { return this.get("interactions")?.get("selectedFeatures"); }, @@ -352,14 +357,14 @@ define([ * zoom to. See {@link CesiumWidgetView#flyTo} for more details on types * of targets. */ - zoomTo: function (target) { + zoomTo(target) { this.get("interactions")?.set("zoomTarget", target); }, /** * Indicate that the map widget view should navigate to the home position. */ - flyHome: function () { + flyHome() { this.zoomTo(this.get("homePosition")); }, @@ -379,7 +384,7 @@ define([ * @returns {MapAssets} The new layers collection. * @since 2.25.0 */ - resetLayers: function () { + resetLayers() { const newLayers = this.defaults()?.layers || new MapAssets(); this.set("layers", newLayers); return newLayers; @@ -410,7 +415,7 @@ define([ * @returns {MapAsset} The new layer model. * @since 2.25.0 */ - addAsset: function (asset) { + addAsset(asset) { const layers = this.get("layers") || this.resetLayers(); return layers.addAsset(asset, this); }, @@ -420,7 +425,7 @@ define([ * @param {MapAsset} asset - The layer model to remove from the map. * @since 2.27.0 */ - removeAsset: function (asset) { + removeAsset(asset) { if (!asset) return; const layers = this.get("layers"); if (!layers) return;