IdentifySource
Asks a service what a raster tile layer shows at a tapped place, as a WMS
GetFeatureInfo request does. The answer is decoded into features that
open the same card as any feature. Nothing is asked until a tap.
This is an interface exported by @mapcairn/core, checked against version 0.2.0.
Signature
import type { IdentifySource } from "@mapcairn/core";
interface IdentifySource
Properties
card
readonly card: CardSpec;
What a found feature's card shows.
decoder
readonly decoder: string;
The name of a registered decoder, such as geojson.
fields
readonly fields: FieldMap;
Where each decoded field comes from. id and title are required.
records
readonly records?: string;
A dotted path to a list in a plain JSON answer. Each item of the list
becomes the properties of one feature at the tapped place, so fields
read properties.name. A path that does not lead to a list finds nothing.
The answer is then handed to decoder as a GeoJSON feature collection.
tolerance
readonly tolerance?: number;
How far from the tap, in CSS pixels, a feature may be and still be
found: a whole number from 1 to 20. Defaults to
DEFAULT_IDENTIFY_TOLERANCE_PX.
url
readonly url: string;
An https URL template, filled by identifyUrl.
Remarks
The URL is a template over the layer's controls and these
variables, all filled by identifyUrl: {lng} and {lat} (the tap, in
degrees), {bbox} (a box around the tap as minx,miny,maxx,maxy in
EPSG:3857 metres), {width} and {height} (the box's size in pixels,
2 * tolerance + 1), {x} and {y} (the tapped pixel in that picture,
which is tolerance) and {zoom} (the normalised zoom). It needs
{lng} and {lat}, or all of {bbox}, {width}, {height}, {x} and
{y}. The origin is fixed in the template, so no placeholder may stand in
the scheme, host or port. The answer must be JSON: GeoJSON, or with
records a list at a path. XML, GML, HTML, plain text and JSONP are not
read, and a POST is not supported. Coordinates in a GeoJSON answer
must be WGS 84 degrees: the decoder drops a position with a longitude
beyond 180 or a latitude beyond 90, so a server that answers in its own
coordinate system reads as nothing found. A feature with no id, or a
null or empty one, takes its position in the answer, which is not stable
from one tap to the next; map fields.id to a real attribute when the
service has one.