Builder

class Builder(sourceId: String)

Builder for GeoJsonSource.

Parameters

sourceId

the ID of the source

Constructors

Builder
Link copied to clipboard
fun Builder(sourceId: String)

Functions

attribution
Link copied to clipboard
fun attribution(value: String): GeoJsonSource.Builder

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

buffer
Link copied to clipboard
fun buffer(value: Long = 128L): GeoJsonSource.Builder

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.

build
Link copied to clipboard
fun build(): GeoJsonSource

Build the GeoJsonSource.

cluster
Link copied to clipboard
fun cluster(value: Boolean = false): GeoJsonSource.Builder

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:

clusterMaxZoom
Link copied to clipboard
fun clusterMaxZoom(value: Long): GeoJsonSource.Builder

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.

clusterProperties
Link copied to clipboard
fun clusterProperties(value: HashMap<String, Any>): GeoJsonSource.Builder

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.

clusterProperty
Link copied to clipboard
fun clusterProperty(propertyName: String, mapExpr: Expression): GeoJsonSource.Builder
fun clusterProperty(propertyName: String, operatorExpr: Expression, mapExpr: Expression): GeoJsonSource.Builder

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.

clusterRadius
Link copied to clipboard
fun clusterRadius(value: Long = 50L): GeoJsonSource.Builder

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

data
Link copied to clipboard
fun data(value: String): GeoJsonSource.Builder

A URL to a GeoJSON file, or inline GeoJSON.

feature
Link copied to clipboard
fun feature(value: Feature): GeoJsonSource.Builder

Add a Feature to the GeojsonSource.

featureCollection
Link copied to clipboard
fun featureCollection(value: FeatureCollection): GeoJsonSource.Builder

Add a FeatureCollection to the GeojsonSource.

generateId
Link copied to clipboard
fun generateId(value: Boolean = false): GeoJsonSource.Builder

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.

geometry
Link copied to clipboard
fun geometry(value: Geometry): GeoJsonSource.Builder

Add a Geometry to the GeojsonSource.

lineMetrics
Link copied to clipboard
fun lineMetrics(value: Boolean = false): GeoJsonSource.Builder

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

maxzoom
Link copied to clipboard
fun maxzoom(value: Long = 18L): GeoJsonSource.Builder

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

prefetchZoomDelta
Link copied to clipboard
fun prefetchZoomDelta(value: Long = 4L): GeoJsonSource.Builder

When loading a map, if PrefetchZoomDelta is set to any number greater than 0, the map will first request a tile at zoom level lower than zoom - delta, but so that the zoom level is multiple of delta, in an attempt to display a full map at lower resolution as quick as possible. It will get clamped at the tile source minimum zoom. The default delta is 4.

promoteId
Link copied to clipboard
fun promoteId(value: PromoteId): GeoJsonSource.Builder

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

tolerance
Link copied to clipboard
fun tolerance(value: Double = 0.375): GeoJsonSource.Builder

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

url
Link copied to clipboard
fun url(value: String): GeoJsonSource.Builder

A URL to a GeoJSON file, or inline GeoJSON.

Properties

sourceId
Link copied to clipboard
val sourceId: String