/location/get

The module exports the location get and getInfoj methods to request location data from the XYZ host.

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.

Parameters:
NameTypeDescription
locationobject
listobject

Object in which locations are stored as properties.

Properties
NameTypeAttributesDescription
location.layerlayer<optional>

The layer to which the location belongs.

location.idstring

The ID must be unique for the layer dataset.

layer.infojArray<optional>

The infoj array from the layer, this is required to decorate the location.

layer.mapviewmapview<optional>
mapview.interactionobject<optional>

The current [highlight] interaction.

mapview.hooksboolean<optional>

Hooks are enabled for the location.layer.mapview.

Returns:

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);
Parameters:
NameTypeDescription
locationObject

The location object containing feature lookup parameters

Properties
NameTypeAttributesDescription
location.layerlayer

Layer information containing features and metadata

layer.featureLocationboolean<optional>

Flag indicating if features are cached locally

layer.featuresArray<optional>

Array of cached feature objects if available locally; Required for layer.featureLocation

location.idstring

ID of the feature to retrieve

location.getTemplatestring

Template name for API query

location.localestring

Locale setting for API query

location.tablestring

Table name for API query

layer.keystring

Fallback layer key identifier

Returns:

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.

Parameters:
NameTypeDescription
locationobject
Properties
NameTypeAttributesDefaultDescription
location.layerlayer

The layer to which the location belongs.

location.getTemplatelayer<optional>
'location_get'

The query template for the location data.

Returns:

The populated location.infoj entries array.

Type: 
Promise.<object>