MvtVectorLayer

open class MvtVectorLayer(var source: TileSource, val minZoom: Int = 0, val maxZoom: Int = 14, val maxLoadedTiles: Int = 256, val maxConcurrentFetches: Int = 4, val maxConcurrentAssembly: Int = 4, val simplifyGeometry: Boolean = true, val simplifyMaxZoom: Int = 12, val useBatchedRendering: Boolean = true, var style: MvtStyle = DefaultMvtStyle, var spriteAtlas: MvtSpriteAtlas? = null, displayName: String? = "Vector Tiles") : MercatorTiledVectorLayer<List<Renderable>>

Renders Mapbox Vector Tile (MVT) data as flat surface-draped polygons and polylines.

Pipeline: HTTP fetch → protobuf decode → command-stream geometry → Web-Mercator unprojection → batched surface drawables (one VBO+EBO per tile per Globe.State).

Tile management — Web-Mercator screen-space-error quadtree selection, the no-overlap cut with ancestor/descendant fallback, LRU + backoff + revalidation — is owned by MercatorTiledVectorLayer / earth.worldwind.layer.TiledVectorLayer. This class supplies only the MVT specifics: tile decode + toRenderables, zoom-interpolated line widths, and the cross-tile label collision pass.

val mvt = MvtVectorLayer(
source = UrlTemplateMvtTileSource("https://tiles.example.com/v3/{z}/{x}/{y}.pbf"),
style = OpenTopoMapRules,
)
worldWindow.engine.layers.addLayer(mvt)
// ...later:
mvt.close()

Constructors

Link copied to clipboard
constructor(source: TileSource, minZoom: Int = 0, maxZoom: Int = 14, maxLoadedTiles: Int = 256, maxConcurrentFetches: Int = 4, maxConcurrentAssembly: Int = 4, simplifyGeometry: Boolean = true, simplifyMaxZoom: Int = 12, useBatchedRendering: Boolean = true, style: MvtStyle = DefaultMvtStyle, spriteAtlas: MvtSpriteAtlas? = null, displayName: String? = "Vector Tiles")

Types

Link copied to clipboard
object Companion
Link copied to clipboard
data class TileKey(val z: Int, val x: Int, val y: Int)

Slippy-map tile coordinate triple (y is slippy, 0=north).

Properties

Link copied to clipboard

Tile keys currently in fetch-failure backoff.

Link copied to clipboard

See TiledImageLayer.cachedSourceInfo — same shape for MVT vector-tile layers.

Link copied to clipboard

Screen-space-error knob: lower = finer (more, smaller on-screen tiles); higher = coarser.

Link copied to clipboard

Schema reported by MvtSchemaDetector for the first non-empty decoded tile. null until detection succeeds; re-runs while UNKNOWN to handle empty first-tile responses.

Link copied to clipboard
open override var displayName: String?
Link copied to clipboard

How hard to coarsen the foreshortened far band (Cesium dynamicScreenSpaceError): a horizon tile gets up to (1 + farBandDetailFactor)× the detail factor, so it carries fewer features. 0 disables.

Link copied to clipboard
open override var isDynamic: Boolean
Link copied to clipboard
open override var isEnabled: Boolean
Link copied to clipboard
open override var isPickEnabled: Boolean
Link copied to clipboard

Tiles currently resident in the content cache (visible + fallback).

Link copied to clipboard
open override var maxActiveAltitude: Double
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Cap on launched-but-unfinished fetch Jobs (vs semaphore, which gates concurrent round-trips); bounds the queue so a huge changing cut can't pile up unbounded coroutines + HTTP/SSL → OOM. Over-cap tiles re-request a later frame.

Link copied to clipboard

Maximum slippy-map zoom the layer will request. Most OpenMapTiles-schema servers stop publishing past z14. Becomes the quadtree's deepest level.

Link copied to clipboard
open override var minActiveAltitude: Double
Link copied to clipboard

Minimum slippy-map zoom the layer will request. Below this the layer stops fetching — features at lower zooms are unreadable at globe-spanning distances and the imagery basemap covers the same role. Becomes the quadtree's fetch floor (levelOffset).

Link copied to clipboard
open override var opacity: Float
Link copied to clipboard

Tiles with a fetch coroutine in flight.

Link copied to clipboard
override val sector: Sector

Vector content bounding sector — real data availability can be smaller than the tile grid. Full sphere by default; tiled layers skip tiles outside it. Cache reopen narrows it from the persisted content bbox; bulk download widens and persists it. Mirrors earth.worldwind.globe.elevation.coverage.ElevationCoverage.sector.

Link copied to clipboard

When true (default), ring/line geometry is RDP+radial simplified at decode; false passes raw verts through.

Link copied to clipboard

Geometry is simplified only at tile zoom <= this (globe/regional scale, where fine detail is sub-pixel and full-detail continental geometry would OOM); at higher zoom (city/street scale) features render full-detail. Applies to both polygon fills and lines.

Link copied to clipboard
Link copied to clipboard

Optional sprite atlas used to resolve icon-image paint to a per-icon image source. When null, rules with icon paint are silently skipped. Load via MvtSpriteAtlasLoader.load.

Link copied to clipboard

Layer-name → ShapeAttributes resolver. Swap to drive a custom appearance.

Link copied to clipboard

When true (default), POLYGON features in a tile are packed into one MvtBatchedPolygonTile and LINESTRING features into one MvtBatchedLineTile — one VBO + one EBO per tile per Globe.State, sub-draws bucketed by (color, width). Set false to fall back to per-feature Polygon/Path instances — required when overriding toRenderables to attach per-feature pick metadata or unique attribute mutations the batched path doesn't carry.

Link copied to clipboard

How many consecutive frames a different zoom must be observed before switching.

Functions

Link copied to clipboard
open override fun clone(): MvtVectorLayer

Makes a fresh copy carrying only this layer's configuration; caches and fetch scope are not shared.

Link copied to clipboard
open override fun close()

Cancel in-flight fetches, release GPU buffers, and free the caches. Idempotent.

Link copied to clipboard

Read all state set for feature. Returns null when no state has been set.

Link copied to clipboard
open override fun getUserProperty(key: Any): Any?
Link copied to clipboard
open override fun hasUserProperty(key: Any): Boolean
Link copied to clipboard

Drop all cached tiles so toRenderables re-runs on the next render. Use after bulk setFeatureState mutations.

Link copied to clipboard
Link copied to clipboard
fun MvtVectorLayer.launchBulkRetrieval(sector: Sector, resolution: ClosedRange<Angle>, scope: CoroutineScope = GlobalScope, maxRetries: Int = 3, retryTimeoutShort: Duration = 5.seconds, retryTimeoutLong: Duration = 15.seconds, overrideCache: Boolean = false, onProgress: (downloaded: Long, skipped: Long, total: Long) -> Unit? = null): Job

Download every MVT tile intersecting sector across the resolution range into the layer's vector-tile store — the "save a region for offline use" flow. Takes the same resolution: ClosedRange<Angle> as TiledImageLayer.launchBulkRetrieval (raster) and TiledElevationCoverage.launchBulkRetrieval (elevation) for a uniform bulk API across layer types; the range is mapped to a slippy zoom range via SlippyTiles.zoomForResolution (nearest-neighbor, matching LevelSet.levelForResolution) and clamped to the layer's MvtVectorLayer.minZoom..MvtVectorLayer.maxZoom.

Link copied to clipboard
open override fun putUserProperty(key: Any, value: Any): Any?
Link copied to clipboard
open override fun removeUserProperty(key: Any): Any?
Link copied to clipboard
open override fun render(rc: RenderContext)
Link copied to clipboard
fun setFeatureState(feature: MvtPickedFeature, key: String, value: Any?)

Set dynamic feature state read by ["feature-state", key] expressions. After mutating state for already-styled features, call invalidate to force re-styling.

Link copied to clipboard
fun VectorLayer.setOfflineOnly(offlineOnly: Boolean = true)

See setOfflineOnly on TiledImageLayer. Dispatches by VectorLayer subtype to reach the right source field. No-op for unknown subtypes.

Link copied to clipboard
fun MvtVectorLayer.tileCount(sector: Sector, resolution: ClosedRange<Angle>): Long

Total number of MVT tiles launchBulkRetrieval would fetch for sector across the resolution range — the slippy analog of LevelSet.tileCount, for sizing a download before committing to it. Uses the same zoom mapping and clamp as launchBulkRetrieval, so the result matches the total later reported to that call's onProgress.