On this page

Type Alias GeoJSONSourceSpecification

type GeoJSONSourceSpecification = {
    attribution?: string;
    buffer?: number;
    cluster?: boolean;
    clusterMaxZoom?: number;
    clusterMinPoints?: number;
    clusterProperties?: unknown;
    clusterRadius?: number;
    data: GeoJSON | string;
    filter?: FilterSpecification;
    generateId?: boolean;
    lineMetrics?: boolean;
    maxzoom?: number;
    promoteId?: PromoteIdSpecification;
    tolerance?: number;
    type: "geojson";
}
Index

Properties

attribution?: string

Contains an attribution to be displayed when the map is shown to a user.

buffer?: number

Size of the tile buffer on each side. A value of 0 produces no buffer. A value of 512 produces a buffer as wide as the tile itself. Larger values produce fewer rendering artifacts near tile edges and slower performance.

128
cluster?: boolean

If the data is a collection of point features, setting this to true clusters the points by radius into groups. Cluster groups become new Point features in the source with additional properties:

  • cluster Is true if the point is a cluster

  • cluster_id A unique id for the cluster to be used in conjunction with the cluster inspection methods

  • point_count Number of original points grouped into this cluster

  • point_count_abbreviated An abbreviated point count

clusterMaxZoom?: number

Max zoom on which to cluster points if clustering is enabled. Defaults to one zoom less than maxzoom (so that last zoom features are not clustered). Clusters are re-evaluated at integer zoom levels so setting clusterMaxZoom to 14 means the clusters will be displayed until z15.

clusterMinPoints?: number

Minimum number of points necessary to form a cluster if clustering is enabled. Defaults to 2.

clusterProperties?: unknown

An object defining custom properties on the generated clusters if clustering is enabled, aggregating values from clustered points. Has the form {"property_name": [operator, map_expression]}. operator is any expression function that accepts at least 2 operands (e.g. "+" or "max") - it accumulates the property value from clusters/points the cluster contains; map_expression produces the value of a single point.

Example: {"sum": ["+", ["get", "scalerank"]]}.

For more advanced use cases, in place of operator, you can use a custom reduce expression that references a special ["accumulated"] value, e.g.:

{"sum": [["+", ["accumulated"], ["get", "sum"]], ["get", "scalerank"]]}

clusterRadius?: number

Radius of each cluster if clustering is enabled. A value of 512 indicates a radius equal to the width of a tile.

50
data: GeoJSON | string

A URL to a GeoJSON file, or inline GeoJSON.

An expression for filtering features prior to processing them for rendering.

generateId?: boolean

Whether to generate ids for the geojson features. When enabled, the feature.id property will be auto assigned based on its index in the features array, over-writing any previous values.

lineMetrics?: boolean

Whether to calculate line distance metrics. This is required for line layers that specify line-gradient values.

maxzoom?: number

Maximum zoom level at which to create vector tiles (higher means greater detail at high zoom levels).

18

A property to use as a feature id (for feature state). Either a property name, or an object of the form {<sourceLayer>: <propertyName>}.

tolerance?: number

Douglas-Peucker simplification tolerance (higher means simpler geometries and faster performance).

0.375
type: "geojson"

The data type of the GeoJSON source.

Was this helpful?
SDK JS
Reference
GeoJSONSourceSpecification