/utils/queryParams
The queryParams module exports the queryParams utility method for layer and dataview requests.
- Source
Methods
(inner) getTable(_this) → {string}
Returns the current table associated with a layer or location.layer which maybe dependent on the mapview zoom level.
Name | Type | Description |
---|---|---|
_this | Object | Object from which the query originates, eg. layer, dataview entry. |
Name | Type | Attributes | Description |
---|---|---|---|
_this.location | location | <optional> | A mapp location associated with _this object. |
location.layer | layer | <optional> | A mapp layer associated with _this.location. |
_this.layer | layer | <optional> | A mapp layer associated with _this object. |
- Source
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.
Name | Type | Description |
---|---|---|
_this | Object | Object from which the query originates, eg. layer, dataview entry. |
Name | Type | Attributes | Description |
---|---|---|---|
_this.queryparams | Object | Parameter object for the query. | |
queryparams.layer | Boolean | <optional> | The layer associated with the requesting object _this should be provided as request param. |
_this.layer | layer | <optional> | The layer associated with _this object. The layer is required to calculate a viewport, center, zoom [z], or table [if not explicit]. |
_this.viewport | Boolean | <optional> | Calculate the bounds for the current viewport of the mapview for _this.layer. |
- Source
A params object to create a params string.
- Type:
- object