Skip to content

Commit

Permalink
Return if queryparams not an object; tidy comments
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-leech committed Oct 13, 2023
1 parent de7f4a0 commit de71034
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/utils/queryParams.mjs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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) {

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit de71034

Please sign in to comment.