Skip to main content

Location Configuration Reference

This page documents every location and map setting available in the template. Configuration flows from your YAML content repository through the SettingsProvider into React components.

Configuration Source

Location settings are defined in the settings.location section of your content repository's works.yml:

settings:
location:
enabled: true
provider: mapbox # 'mapbox' or 'google'
map_style: streets # 'streets' or 'satellite'
distance_filter_enabled: true
distance_sort_enabled: true
default_radius_km: 50
show_exact_address: false
require_location_on_submit: false
default_center: [40.7128, -74.0060] # [latitude, longitude]

Configuration Types

LocationConfigSettings (YAML / snake_case)

The raw shape read from works.yml, defined in lib/types/location.ts:

interface LocationConfigSettings {
enabled?: boolean;
provider?: MapProvider;
map_style?: MapStyle;
distance_filter_enabled?: boolean;
distance_sort_enabled?: boolean;
default_radius_km?: number;
show_exact_address?: boolean;
require_location_on_submit?: boolean;
default_center?: [number, number]; // [latitude, longitude]
}

LocationSettings (Runtime / camelCase)

The runtime shape used throughout the application:

interface LocationSettings {
enabled: boolean;
provider: MapProvider;
mapStyle: MapStyle;
distanceFilterEnabled: boolean;
distanceSortEnabled: boolean;
defaultRadiusKm: number;
showExactAddress: boolean;
requireLocationOnSubmit: boolean;
defaultCenter: { latitude: number; longitude: number };
}

The mapLocationConfigToRuntime() function converts snake_case YAML settings to the camelCase runtime format.

Setting Descriptions

SettingTypeDefaultDescription
enabledbooleanfalseMaster switch for all location features
providerMapProvider'mapbox'Map tile and geocoding provider
mapStyleMapStyle'streets'Map rendering style
distanceFilterEnabledbooleantrueShow distance radius filter in search
distanceSortEnabledbooleantrueAllow sorting results by distance
defaultRadiusKmnumber50Default search radius in kilometres
showExactAddressbooleanfalseDisplay full addresses publicly
requireLocationOnSubmitbooleanfalseMake location required for submissions
defaultCenter{lat, lng}{0, 0}Fallback map center coordinates

Map Providers

MapProvider

type MapProvider = 'mapbox' | 'google';
ProviderEnv VarFeatures
MapboxNEXT_PUBLIC_MAPBOX_TOKENVector tiles, geocoding, clustering
Google MapsNEXT_PUBLIC_GOOGLE_MAPS_KEYTiles, Places API, geocoding

MapStyle

type MapStyle = 'streets' | 'satellite';

MapProviderStatus

API key status for the admin UI.

interface MapProviderStatus {
provider: MapProvider;
isConfigured: boolean;
displayName: string;
}

MapStatusResponse

Response from the /api/map-status endpoint.

interface MapStatusResponse {
mapbox: { isConfigured: boolean; isPreviewAvailable: boolean; name: string };
google: { isConfigured: boolean; isPreviewAvailable: boolean; name: string };
}

Coordinate System

Coordinates

The standard geographic point type used across all map components.

interface Coordinates {
latitude: number;
longitude: number;
}

MapBounds

Bounding box for viewport calculations.

interface MapBounds {
north: number;
south: number;
east: number;
west: number;
}

GeoBoundingBox

Alternative bounding box for database queries.

interface GeoBoundingBox {
minLat: number;
maxLat: number;
minLng: number;
maxLng: number;
}

Location Data

LocationData

Item location stored in the item_location_index database table.

interface LocationData {
item_slug: string;
latitude: number;
longitude: number;
address: string | null;
city: string | null;
state: string | null;
country: string | null;
postal_code: string | null;
service_area: string | null;
is_remote: boolean;
indexed_at: Date;
}

LocationQueryOptions

Parameters for proximity-based item searches.

interface LocationQueryOptions {
latitude?: number;
longitude?: number;
radiusKm?: number;
city?: string;
country?: string;
includeRemote?: boolean;
}

LocationQueryResult

Result of a location-based search.

interface LocationQueryResult {
itemSlug: string;
distanceKm?: number;
city: string | null;
country: string | null;
}

Map Component Configuration

MapComponentProps

Props for the main Map component.

interface MapComponentProps {
markers?: MapMarkerData[];
center?: Coordinates;
zoom?: number; // 1-20
style?: MapStyle;
className?: string;
height?: string | number;
controls?: MapControlsConfig;
enableClustering?: boolean;
clusterOptions?: ClusterOptions;
isLoading?: boolean;
onMarkerClick?: (marker: MapMarkerData) => void;
onViewportChange?: (viewport: MapViewport) => void;
}

ClusterOptions

Marker clustering configuration.

interface ClusterOptions {
radius?: number; // Cluster radius in pixels (default: 60)
maxZoom?: number; // Max zoom for clustering (default: 16)
minZoom?: number; // Min zoom for clustering (default: 0)
minPoints?: number; // Min points to form cluster (default: 2)
}

MapControlsConfig

Toggle map UI controls.

interface MapControlsConfig {
showZoomControls?: boolean;
showFullscreenControl?: boolean;
showNavigationControl?: boolean;
showScaleControl?: boolean;
}

User Location Preferences

Users can set default location preferences in their client profile (stored in client_profiles table):

ColumnTypeDescription
default_latitudedoublePrecisionUser's default latitude
default_longitudedoublePrecisionUser's default longitude
default_citytextUser's default city
default_countrytextUser's default country
location_privacytext'private' (default) or 'public'

Environment Variables

Env VarRequiredDescription
NEXT_PUBLIC_MAPBOX_TOKENFor MapboxMapbox GL access token
NEXT_PUBLIC_GOOGLE_MAPS_KEYFor GoogleGoogle Maps API key