diff --git a/lib/utils/queryParams.mjs b/lib/utils/queryParams.mjs index 7f2b135674..deaa281979 100644 --- a/lib/utils/queryParams.mjs +++ b/lib/utils/queryParams.mjs @@ -1,7 +1,10 @@ export default _this => { - // Assign empty object if not defined. - _this.queryparams ??= {} + // If queryparams is not an object, return. + if (typeof _this.queryparams !== 'object') { + console.warn('queryparams must be an object') + return; + }; // The layer queryparam must be true to support viewport params. _this.queryparams.layer = _this.queryparams.layer || _this.viewport @@ -13,7 +16,7 @@ export default _this => { let table = _this.queryparams.table === true ? tableCurrent : _this.queryparams.table; _this.queryparams.table &&= table; - + // Assign fieldValues from the location to queryparams. if (Array.isArray(_this.queryparams.fieldValues) && _this.location) { @@ -49,20 +52,20 @@ export default _this => { // Locale param is only required for layer lookups. locale: _this.queryparams.layer && _this.layer.mapview.locale.key, - // Locale param is only required for layer lookups. + // Layer param is only required for layer lookups. layer: _this.queryparams.layer && _this.layer.key, // ID will be taken if a location object is provided with the params. id: _this.queryparams?.id && _this.location?.id, - // lat lng must be explicit or the the center flag param must be set. + // lat lng must be explicit or the center flag param must be set. lat: center && center[1], lng: center && center[0], - // z will generated if the z flag is set in the params. + // z will be generated if the z flag is set in the params. z: _this.queryparams?.z && _this.layer.mapview.Map.getView().getZoom(), - // Viewport will onlcy be generated if the viewport flag is set on the params. + // Viewport will only be generated if the viewport flag is set on the params. viewport: bounds && [bounds.west, bounds.south, bounds.east, bounds.north, _this.layer.mapview.srid], // The fieldValues array entries should not be part of the url params.