GeoJsonSource

A GeoJSON data source.

See also

Types

Link copied to clipboard
class Builder(val sourceId: String)

Builder for GeoJsonSource.

Link copied to clipboard
object Companion

Static variables and methods.

Functions

Link copied to clipboard
open override fun bindTo(delegate: MapboxStyleManager)

Add the GeoJsonSource to the Style.

Link copied to clipboard
@JvmOverloads
fun data(value: String, dataId: String = ""): GeoJsonSource

Sets GeoJson data property as a String. value could be an URL to a GeoJSON file, or an inline GeoJSON.

Link copied to clipboard
@JvmOverloads
fun feature(value: Feature, dataId: String = ""): GeoJsonSource

Add a Feature to the GeojsonSource. The data will be scheduled and applied on a worker thread.

Link copied to clipboard
@JvmOverloads
fun featureCollection(value: FeatureCollection, dataId: String = ""): GeoJsonSource

Add a Feature Collection to the GeojsonSource. The data will be scheduled and applied on a worker thread.

Link copied to clipboard
@JvmOverloads
fun geometry(value: Geometry, dataId: String = ""): GeoJsonSource

Add a Geometry to the GeojsonSource. The data will be scheduled and applied on a worker thread.

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

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. Default value: 4.

Link copied to clipboard
fun tileCacheBudget(value: TileCacheBudget): GeoJsonSource

This property defines a source-specific resource budget, either in tile units or in megabytes. Whenever the tile cache goes over the defined limit, the least recently used tile will be evicted from the in-memory cache. Note that the current implementation does not take into account resources allocated by the visible tiles.

Link copied to clipboard
open override fun toString(): String

Returns a human readable string that includes the cached properties of the source.

Link copied to clipboard
@JvmOverloads
fun url(value: String, dataId: String = ""): GeoJsonSource

Properties

Link copied to clipboard
val attribution: String?

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

Link copied to clipboard
val buffer: Long?

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. Default value: 128. Value range: 0, 512

Link copied to clipboard
val 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:

Link copied to clipboard
val clusterMaxZoom: Long?

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.

Link copied to clipboard
val clusterMinPoints: Long?

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

Link copied to clipboard
val clusterProperties: HashMap<String, Any>?

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.

Link copied to clipboard
val clusterRadius: Long?

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

Link copied to clipboard
val data: String?

A URL to a GeoJSON file, or inline GeoJSON.

Link copied to clipboard
val 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. Default value: false.

Link copied to clipboard
val lineMetrics: Boolean?

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

Link copied to clipboard
val maxzoom: Long?

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

Link copied to clipboard

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. Default value: 4.

Link copied to clipboard

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

Link copied to clipboard
val sourceId: String

The ID of the Source.

Link copied to clipboard
val tileCacheBudget: TileCacheBudget?

This property defines a source-specific resource budget, either in tile units or in megabytes. Whenever the tile cache goes over the defined limit, the least recently used tile will be evicted from the in-memory cache. Note that the current implementation does not take into account resources allocated by the visible tiles.

Link copied to clipboard
val tolerance: Double?

Douglas-Peucker simplification tolerance (higher means simpler geometries and faster performance). Default value: 0.375.

Extensions

Link copied to clipboard
@JvmOverloads
fun GeoJsonSource.addGeoJSONSourceFeatures(features: List<Feature>, dataId: String = "")

Add additional features to a GeoJSON style source. The data will be scheduled and applied on a worker thread.

Link copied to clipboard
@JvmOverloads
fun GeoJsonSource.removeGeoJSONSourceFeatures(featureIds: List<String>, dataId: String = "")

Remove features from a GeoJSON style source. The data will be scheduled and applied on a worker thread.

Link copied to clipboard
@JvmOverloads
fun GeoJsonSource.updateGeoJSONSourceFeatures(features: List<Feature>, dataId: String = "")

Update existing features in a GeoJSON style source. The data will be scheduled and applied on a worker thread.