/** * Shared types for the Xertica map family. * * Everything that is consumed by more than one map component lives here so that * `Map`, `MapLegend`, `MapNotice` and `MapViewControl` all speak the same * vocabulary. Keep this module free of React and of `google.maps` imports — it * is loaded by pure utilities (`map-scale.ts`) that must stay testable without * the Google Maps script. */ /** * Re-exported from `shared` so the map and the graph share one definition. * * The Google Maps API only accepts literal color values, so every map surface * takes a token name and resolves it at runtime through `useMapTokenColor`. * That indirection is what makes map color follow a theme switch instead of * freezing at mount. */ export type { ColorToken } from '../../shared/color-token'; export interface LatLng { lat: number; lng: number; } /** * Maps a data value to a pixel size — the basis of proportional symbology. * * `method` defaults to `'sqrt'` because that makes the rendered *area* (not the * radius) proportional to `value`, which is what keeps a circle honest as a * quantity encoding. */ export interface MapScale { value: number; domain: [number, number]; /** Output size range, in pixels. */ range: [number, number]; /** @default 'sqrt' */ method?: 'linear' | 'sqrt' | 'log'; } /** * How a point's position was obtained. Surfaced to the user so that a centroid * used for anonymization is never mistaken for a precise location. */ export type MapPrecision = 'exact' | 'centroid' | 'jittered'; export type MapOverlayPosition = 'top-left' | 'top-center' | 'top-right' | 'middle-left' | 'middle-center' | 'middle-right' | 'bottom-left' | 'bottom-center' | 'bottom-right'; /** * Kind of feature a selection/hover event refers to. * * Only `'marker'` is emitted in the current release; the remaining members are * declared up front so that consumer `switch` statements written today stay * exhaustive as geometries, GeoJSON and clusters start emitting events. */ export type MapFeatureKind = 'marker' | 'cluster' | 'polygon' | 'circle' | 'polyline' | 'sector' | 'geojson' | 'annotation'; /** Identifies the feature that triggered a selection or hover event. */ export interface MapFeatureRef { id: string; kind: MapFeatureKind; /** Present for point-like features. */ position?: LatLng; /** Index within the source array, when the feature came from one. */ index?: number; /** Whatever the consumer attached to the source feature. */ data?: unknown; }