Skip to main content

<ShapeSource />

ShapeSource is a map content source that supplies vector shapes to be shown on the map.
The shape may be a url or a GeoJSON object

Props

PropTypeDefaultRequiredDescription
idstringMLRNModule.StyleSource.DefaultSourceIDfalseA string that uniquely identifies the source.
urlstringnonefalseAn HTTP(S) URL, absolute file URL, or local file URL relative to the current application’s resource bundle.
shapeGeoJSON.GeometryCollection | GeoJSON.Feature | GeoJSON.FeatureCollection | GeoJSON.GeometrynonefalseThe contents of the source. A shape can represent a GeoJSON geometry, a feature, or a feature colllection.
clusterbooleannonefalseEnables clustering on the source for point shapes.
clusterRadiusnumbernonefalseSpecifies the radius of each cluster if clustering is enabled.
A value of 512 produces a radius equal to the width of a tile.
The default value is 50.
clusterMaxZoomLevelnumbernonefalseSpecifies the maximum zoom level at which to cluster points if clustering is enabled.
Defaults to one zoom level less than the value of maxZoomLevel so that, at the maximum zoom level,
the shapes are not clustered.
clusterPropertiesshapenonefalseSpecifies custom properties on the generated clusters if clustering
is enabled, aggregating values from clustered points.

Has the form { "property_name": [operator, map_expression]}, where
operator is a custom reduce expression that references a special ["accumulated"] value -
it accumulates the property value from clusters/points the cluster contains
map_expression produces the value of a single point

@example { "resultingSum": [["+", ["accumulated"], ["get", "resultingSum"]], ["get", "scalerank"]] }
  [object Object]ExpressionFieldnonetrueFIX ME NO DESCRIPTION
maxZoomLevelnumbernonefalseSpecifies the maximum zoom level at which to create vector tiles.
A greater value produces greater detail at high zoom levels.
The default value is 18.
buffernumbernonefalseSpecifies the 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.
The default value is 128.
tolerancenumbernonefalseSpecifies the Douglas-Peucker simplification tolerance.
A greater value produces simpler geometries and improves performance.
The default value is 0.375.
lineMetricsbooleannonefalseWhether to calculate line distance metrics.
This is required for line layers that specify lineGradient values.
The default value is false.
onPressfuncnonefalseSource press listener, gets called when a user presses one of the children layers only if that layer has a higher z-index than another source layers.
signature:(event:OnPressEvent) => void
hitboxshapenonefalseOverrides the default touch hitbox (44x44 pixels) for the source layers
  widthnumbernonetruewidth of hitbox
  heightnumbernonetrueheight of hitbox
childrenReactNodenonefalseFIX ME NO DESCRIPTION

Methods

features([filter])

Returns all features from the source that match the query parameters regardless of whether or not the feature is
currently rendered on the map.

Arguments

NameTypeRequiredDescription
filterFilterExpressionNoan optional filter statement to filter the returned Features.
shapeSource.features();

getClusterExpansionZoom(feature)

Returns the zoom needed to expand the cluster.

Arguments

NameTypeRequiredDescription
featureGeoJSON.FeatureYesThe feature cluster to expand.
const zoom = await shapeSource.getClusterExpansionZoom(clusterId);

getClusterLeaves(feature, limit, offset)

Returns the FeatureCollection from the cluster.

Arguments

NameTypeRequiredDescription
featureGeoJSON.FeatureYesThe feature cluster to expand.
limitnumberYesThe number of points to return.
offsetnumberYesThe amount of points to skip (for pagination).
const collection = await shapeSource.getClusterLeaves(clusterId, limit, offset);

getClusterChildren(feature)

Returns the FeatureCollection from the cluster (on the next zoom level).

Arguments

NameTypeRequiredDescription
featureGeoJSON.FeatureYesThe feature cluster to expand.
const collection = await shapeSource.getClusterChildren(clusterId);

onPress(event)

Arguments

NameTypeRequiredDescription
eventNativeSyntheticEventYesundefined