@d3-maps/core / map
map
Table of contents
Functions
getTopoObject()
function getTopoObject(geoData: Topology): GeometryObject;Parameters
| Parameter | Type |
|---|---|
geoData | Topology |
Returns
GeometryObject
isTopology()
function isTopology(data: MapData): data is Topology<Objects<GeoJsonProperties>>;Type guard for TopoJSON topology inputs.
Parameters
| Parameter | Type |
|---|---|
data | MapData |
Returns
data is Topology<Objects<GeoJsonProperties>>
makeFeatures()
function makeFeatures(geoData: MapData, dataTransformer?: DataTransformer): MapFeature[];Normalizes input map data to GeoJSON features.
- TopoJSON is converted via
topojson-client. - If provided,
dataTransformeris applied to the feature array.
Parameters
| Parameter | Type |
|---|---|
geoData | MapData |
dataTransformer? | DataTransformer |
Returns
makeMapContext()
function makeMapContext(__namedParameters: MapConfig): MapContext;Creates a full MapContext from a MapConfig.
Parameters
| Parameter | Type |
|---|---|
__namedParameters | MapConfig |
Returns
makeMesh()
function makeMesh(geoData: MapData): MultiLineString | undefined;Returns a TopoJSON mesh when topology data is provided.
Parameters
| Parameter | Type |
|---|---|
geoData | MapData |
Returns
MultiLineString | undefined
makeProjection()
function makeProjection(__namedParameters: {
config?: ProjectionConfig;
height: number;
projection: () => GeoProjection;
width: number;
}): GeoProjection;Creates a configured projection and fits it to the provided GeoJSON (if present).
Parameters
| Parameter | Type |
|---|---|
__namedParameters | { config?: ProjectionConfig; height: number; projection: () => GeoProjection; width: number; } |
__namedParameters.config? | ProjectionConfig |
__namedParameters.height | number |
__namedParameters.projection | () => GeoProjection |
__namedParameters.width | number |
Returns
GeoProjection
Interfaces
MapConfig
Input configuration for creating a map context.
In adapters, this is usually passed as component props.
Properties
| Property | Type | Description |
|---|---|---|
aspectRatio? | number | - |
data | MapData | TopoJSON or GeoJSON input. TopoJSON is automatically converted to GeoJSON features. |
dataTransformer? | DataTransformer | Optional feature transformer (filter/augment/normalize features). |
height? | number | - |
projection? | () => GeoProjection | Projection factory from d3-geo (or a compatible implementation). Example: geoNaturalEarth1. |
projectionConfig? | ProjectionConfig | Projection method arguments passed to the created projection |
width? | number | - |
MapContext
Fully computed, framework-agnostic map context.
Adapters provide this context to child layers (features, markers, custom SVG).
Properties
| Property | Type |
|---|---|
features | MapFeature[] |
height | number |
path | GeoPath |
projection? | GeoProjection |
renderMesh | () => void |
width | number |
ProjectionConfig
Extra projection method calls to apply before rendering.
Use projection method names as keys and method arguments as values. Example: { center: [[0, 20]], rotate: [[0, 0, 0]], scale: 160 }
See
https://d3js.org/d3-geo/projection
Extends
Omit<MethodsToModifiers<GeoProjection>,"invert"|"stream">
Properties
| Property | Type | Inherited from |
|---|---|---|
angle? | number | [number] |
center? | [[number, number]] | ProjectionConfig.center |
clipAngle? | number | [number] |
clipExtent? | [[[number, number], [number, number]]] | [null] |
fitExtent? | [[[number, number], [number, number]], | GeoGeometryObjects |
fitHeight? | [number, | GeoGeometryObjects |
fitSize? | [[number, number], | GeoGeometryObjects |
fitWidth? | [number, | GeoGeometryObjects |
postclip? | (stream: GeoStream) => GeoStream | |
precision? | number | [number] |
preclip? | (stream: GeoStream) => GeoStream | |
reflectX? | boolean | [false] |
reflectY? | boolean | [false] |
rotate? | [[number, number]] | [[number, number, number]] |
scale? | number | [number] |
translate? | [[number, number]] | ProjectionConfig.translate |
Type Aliases
DataTransformer()
type DataTransformer = (features: MapFeature[]) => MapFeature[];Parameters
| Parameter | Type |
|---|---|
features | MapFeature[] |
Returns
MapData
type MapData = ExtendedFeatureCollection | Topology;MapMesh
type MapMesh = ReturnType<typeof mesh>;