/utils/queryParams

The queryParams module exports the queryParams utility method for layer and dataview requests.

Methods

(inner) getTable(_this) → {string}

Returns the current table associated with a layer or location.layer which maybe dependent on the mapview zoom level.

Parameters:
NameTypeDescription
_thisObject

Object from which the query originates, eg. layer, dataview entry.

Properties
NameTypeAttributesDescription
_this.locationlocation<optional>

A mapp location associated with _this object.

location.layerlayer<optional>

A mapp layer associated with _this.location.

_this.layerlayer<optional>

A mapp layer associated with _this object.

Returns:

Table name

Type: 
string

(inner) queryParams(_this) → {object}

The queryParams method returns a params object for the creation of a query URL params string.

The utility facilitates the creation of params argument for the mapp.utils.paramString() method.

from the dataview.update() method.

// Compile params object from dataview this.
const params = mapp.utils.queryParams(this);

// Stringify paramString from object.
const paramString = mapp.utils.paramString(params);

this.host ??= this.layer?.mapview?.host

// Query data as response from query.
const response = await mapp.utils.xhr(`${this.host || mapp.host}/api/query?${paramString}`);

The queryParams method is particularly useful for calculating the current [viewport] bounds for a data query and to determine the current table for the mapviews current zoom level.

Parameters:
NameTypeDescription
_thisObject

Object from which the query originates, eg. layer, dataview entry.

Properties
NameTypeAttributesDescription
_this.queryparamsObject

Parameter object for the query.

queryparams.layerBoolean<optional>

The layer associated with the requesting object _this should be provided as request param.

_this.layerlayer<optional>

The layer associated with _this object. The layer is required to calculate a viewport, center, zoom [z], or table [if not explicit].

_this.viewportBoolean<optional>

Calculate the bounds for the current viewport of the mapview for _this.layer.

Returns:

A params object to create a params string.

Type: 
object