@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): MapFeatureData[];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: MapProps): MapContext;Creates a full MapContext from a MapProps.
Parameters
| Parameter | Type |
|---|---|
__namedParameters | MapProps |
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
MapContext
Fully computed, framework-agnostic map context.
Adapters provide this context to child layers (features, markers, custom SVG).
Properties
| Property | Type | Description |
|---|---|---|
features | MapFeatureData[] | Normalized feature list after optional transformation. |
height | number | Resolved SVG height used by the map. |
path | GeoPath | Shared path generator bound to the map projection. |
projection | GeoProjection | Configured projection instance shared by map layers. |
renderMesh | () => string | null |
width | number | Resolved SVG width used by the map. |
MapProps
Shared props contract for the Map component.
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 | - |
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: MapFeatureData[]) => MapFeatureData[];Parameters
| Parameter | Type |
|---|---|
features | MapFeatureData[] |
Returns
MapData
type MapData = ExtendedFeatureCollection | Topology;MapMeshData
type MapMeshData = ReturnType<typeof mesh>;