/location/get
The module exports the location get and getInfoj methods to request location data from the XYZ host.
- Source
Requires
Methods
(inner) get(location, list) → {Promise.<object>}
The method will shortcircuit if a default getLocation method has been assigned to the [highlight] interaction.
The get method assigns a unique location.hook composed from the location.layer.key and the location.id.
The layer.key being unique to the locale, and the id being unique to the layer makes the location.hook unique to the mapview.
A location will be removed from the list object param if the location already exists in the list. Otherwise the location will be assigned as a property to the list object.
The getInfoj() method is awaited before the location is decorated.
Name | Type | Description |
---|---|---|
location | object | |
list | object | Object in which locations are stored as properties. |
Name | Type | Attributes | Description |
---|---|---|---|
location.layer | layer | <optional> | The layer to which the location belongs. |
location.id | string | The ID must be unique for the layer dataset. | |
layer.infoj | Array | <optional> | The infoj array from the layer, this is required to decorate the location. |
layer.mapview | mapview | <optional> | |
mapview.interaction | object | <optional> | The current [highlight] interaction. |
mapview.hooks | boolean | <optional> | Hooks are enabled for the location.layer.mapview. |
- Source
Decorated location
- Type:
- Promise.<object>
(async, inner) getFeatureResponse(location) → {Promise.<(Object|null)>}
Retrieves a feature either from local cache or remote API based on location parameters
const location = {
layer: {
featureLocation: true,
features: [{properties: {id: '123'}, geometry: {...}}]
},
id: '123',
getTemplate: 'default',
locale: 'en',
table: 'locations'
};
const feature = await getFeatureResponse(location);
Name | Type | Description |
---|---|---|
location | Object | The location object containing feature lookup parameters |
Name | Type | Attributes | Description |
---|---|---|---|
location.layer | layer | Layer information containing features and metadata | |
layer.featureLocation | boolean | <optional> | Flag indicating if features are cached locally |
layer.features | Array | <optional> | Array of cached feature objects if available locally; Required for layer.featureLocation |
location.id | string | ID of the feature to retrieve | |
location.getTemplate | string | Template name for API query | |
location.locale | string | Locale setting for API query | |
location.table | string | Table name for API query | |
layer.key | string | Fallback layer key identifier |
- Source
A promise that resolves to either:
- An object containing the feature geometry and properties if found
- null if no matching feature is found locally
- API response if fetched remotely
- Type:
- Promise.<(Object|null)>
(inner) getInfoj(location) → {Promise.<object>}
The method sends a parameterised query to the location.getTemplate query template.
The response is expected to be an object, not an array.
The response properties are mapped into clones of the layer.infoj which will be assigned to the location.
Name | Type | Description |
---|---|---|
location | object |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
location.layer | layer | The layer to which the location belongs. | ||
location.getTemplate | layer | <optional> | 'location_get' | The query template for the location data. |
- Source
The populated location.infoj entries array.
- Type:
- Promise.<object>