GeoJsonSource

A GeoJSON data source.

class GeoJsonSource(builder: GeoJsonSource.Builder) : Source

See also

<a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#geojson">The online documentation</a>

Constructors

GeoJsonSource
Link copied to clipboard
fun GeoJsonSource(builder: GeoJsonSource.Builder)

Types

Builder
Link copied to clipboard

Builder for GeoJsonSource.

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

Static variables and methods.

object Companion

Functions

bindTo
Link copied to clipboard

Add the source to the Style.

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

A URL to a GeoJSON file, or inline GeoJSON.

fun data(value: Expression): GeoJsonSource
fun data(value: String): GeoJsonSource
equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
feature
Link copied to clipboard

Add a Feature to the GeojsonSource.

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

Add a FeatureCollection to the GeojsonSource.

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

Add a Geometry to the GeojsonSource.

fun geometry(value: Geometry): GeoJsonSource
getCachedSourceProperties
Link copied to clipboard
override fun getCachedSourceProperties(): Value
hashCode
Link copied to clipboard
open override fun hashCode(): Int
prefetchZoomDelta
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 for zoom - delta in a 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.

fun prefetchZoomDelta(value: Expression): GeoJsonSource
fun prefetchZoomDelta(value: Long): GeoJsonSource
toString
Link copied to clipboard

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

open override fun toString(): String
updateProperty
Link copied to clipboard
override fun updateProperty(property: PropertyValue<*>)
url
Link copied to clipboard

A URL to a GeoJSON file, or inline GeoJSON.

fun url(value: Expression): GeoJsonSource
fun url(value: String): GeoJsonSource

Properties

attribution
Link copied to clipboard

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

val attribution: String?
attributionAsExpression
Link copied to clipboard

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

val attributionAsExpression: Expression?
buffer
Link copied to clipboard

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.

val buffer: Long?
bufferAsExpression
Link copied to clipboard

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.

val bufferAsExpression: Expression?
cluster
Link copied to clipboard

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 unqiue 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

val cluster: Boolean?
clusterAsExpression
Link copied to clipboard

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 unqiue 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

val clusterAsExpression: Expression?
clusterMaxZoom
Link copied to clipboard

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.

val clusterMaxZoom: Long?
clusterMaxZoomAsExpression
Link copied to clipboard

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.

val clusterMaxZoomAsExpression: Expression?
clusterProperties
Link copied to clipboard

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"]]}

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

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"]]}

val clusterPropertiesAsExpression: Expression?
clusterRadius
Link copied to clipboard

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

val clusterRadius: Long?
clusterRadiusAsExpression
Link copied to clipboard

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

val clusterRadiusAsExpression: Expression?
data
Link copied to clipboard

A URL to a GeoJSON file, or inline GeoJSON.

Note: Getter for plain Geojson string data is not supported due to performance consideration.

val data: String?
dataAsExpression
Link copied to clipboard

A URL to a GeoJSON file, or inline GeoJSON.

Note: Getter for plain Geojson string data is not supported due to performance consideration.

val dataAsExpression: Expression?
lineMetrics
Link copied to clipboard

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

val lineMetrics: Boolean?
lineMetricsAsExpression
Link copied to clipboard

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

val lineMetricsAsExpression: Expression?
maxzoom
Link copied to clipboard

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

val maxzoom: Long?
maxzoomAsExpression
Link copied to clipboard

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

val maxzoomAsExpression: Expression?
prefetchZoomDelta
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 for zoom - delta in a 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.

val prefetchZoomDelta: Long?
prefetchZoomDeltaAsExpression
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 for zoom - delta in a 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.

val prefetchZoomDeltaAsExpression: Expression?
sourceId
Link copied to clipboard

The ID of the Source.

override val sourceId: String
tolerance
Link copied to clipboard

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

val tolerance: Double?
toleranceAsExpression
Link copied to clipboard

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

val toleranceAsExpression: Expression?

Extensions

getClusterChildren
Link copied to clipboard

Returns the children of a cluster (on the next zoom level).

fun GeoJsonSource.getClusterChildren(clusterId: Int): MutableList<Feature>
getClusterLeaves
Link copied to clipboard

Returns all the leaves of a cluster (given its cluster_id), with pagination support: limit is the number of leaves to return (set to Infinity for all points), and offset is the amount of points to skip (for pagination).

fun GeoJsonSource.getClusterLeaves(clusterId: Int, limit: Int, offset: Int): MutableList<Feature>
getExpansionZoom
Link copied to clipboard

Returns the zoom on which the cluster expands into several children (useful for "click to zoom" feature).

fun GeoJsonSource.getExpansionZoom(clusterId: Int): Byte