MSFTerrainOptions

Objective-C


@interface MSFTerrainOptions : NSObject {
  void *swigCPtr;
  BOOL swigCMemOwn;
}

Swift

class MSFTerrainOptions : NSObject

3D terrain configuration, attached to the map via Options::setTerrainOptions. The elevation data source can be shared with a HillshadeRasterTileLayer, in which case both features use the same tiles (ideally the data source should be wrapped in a MemoryCacheTileDataSource to avoid duplicate loads). Note: this class is experimental and may change or even be removed in future SDK versions.

  • Constructs a TerrainOptions object from an elevation data source. The elevation decoder is resolved from the data source “encoding” setting (“mapbox” or “terrarium”), defaulting to the MapBox encoding.

    Declaration

    Objective-C

    - (id)initWithDataSource:(MSFTileDataSource *)dataSource;

    Swift

    init!(dataSource: MSFTileDataSource!)

    Parameters

    dataSource

    The data source with RGB-encoded elevation tiles.

  • Constructs a TerrainOptions object from an elevation data source and an explicit decoder.

    Declaration

    Objective-C

    - (id)initWithDataSource:(MSFTileDataSource *)dataSource
            elevationDecoder:(MSFElevationDecoder *)elevationDecoder;

    Swift

    init!(dataSource: MSFTileDataSource!, elevationDecoder: MSFElevationDecoder!)

    Parameters

    dataSource

    The data source with RGB-encoded elevation tiles.

    elevationDecoder

    The decoder for the elevation tile encoding.

  • Returns the elevation data source.

    Declaration

    Objective-C

    - (MSFTileDataSource *)getDataSource;

    Swift

    func getDataSource() -> MSFTileDataSource!

    Return Value

    The elevation data source.

  • Returns the elevation decoder used as the source-level default. Each tile resolves its own decoder from its “dem_encoding” meta data, so two data sources of different encodings can be combined behind one OrderedTileDataSource.

    Declaration

    Objective-C

    - (MSFElevationDecoder *)getElevationDecoder;

    Swift

    func getElevationDecoder() -> MSFElevationDecoder!

    Return Value

    The default elevation decoder.

  • Returns the enabled state of the terrain.

    Declaration

    Objective-C

    - (BOOL)isEnabled;

    Swift

    func isEnabled() -> Bool

    Return Value

    True if 3D terrain rendering is enabled. The default is true.

  • Sets the enabled state of the terrain. If disabled, the map renders flat, but the elevation data source stays attached.

    Declaration

    Objective-C

    - (void)setEnabled:(BOOL)enabled;

    Swift

    func setEnabled(_ enabled: Bool)

    Parameters

    enabled

    The new enabled state.

  • Returns whether the map is asked to render flat. This is the 2D/3D state, whether it was set by the app or by auto-flattening; the switch itself is animated, so for a moment after a change the map is still on its way there.

    Declaration

    Objective-C

    - (BOOL)isFlattened;

    Swift

    func isFlattened() -> Bool

    Return Value

    True if the map is flat, or on its way to flat. The default is false.

  • Switches the map between flat and 3D terrain, without detaching the elevation data the way setEnabled does. Auto-flattening writes the same state, so an app driving this itself normally turns auto off (setAutoFlattenParallax(0) and setAutoFlattenTilt(0)). What the switch costs, and whether a flat map goes on paying for 3D, is setFlattenMode. An app that starts in 2D sets this before it adds its layers, so nothing decodes for 3D.

    Declaration

    Objective-C

    - (void)setFlattened:(BOOL)flattened;

    Swift

    func setFlattened(_ flattened: Bool)

    Parameters

    flattened

    True to render flat.

  • Returns how far a flattened terrain goes back towards a plain 2D map.

    Declaration

    Objective-C

    - (enum MSFTerrainFlattenMode)getFlattenMode;

    Swift

    func getFlattenMode() -> MSFTerrainFlattenMode

    Return Value

    The flatten mode. The default is TERRAIN_FLATTEN_MODE_RENDER.

  • Sets how far a flattened terrain goes back towards a plain 2D map. RENDER is the cheap switch: the terrain passes stop, but the tiles keep the subdivision 3D needed, so a flat map still draws a 3D map’s triangles. FULL drops that too - a flat map decodes, culls and draws as if no terrain were configured - at the price of re-decoding the visible tiles at every switch.

    That re-decode is not visible: it is made while the map is already flat, where the two densities draw the same picture, and the tiles being replaced stay on screen until their replacement arrives. Going back to 3D waits for the tiles it needs before it starts to rise, so the wait shows as 3D arriving late rather than as a half-built map.

    Declaration

    Objective-C

    - (void)setFlattenMode:(enum MSFTerrainFlattenMode)mode;

    Swift

    func setFlattenMode(_ mode: MSFTerrainFlattenMode)

    Parameters

    mode

    The new flatten mode.

  • Returns how far the terrain is flattened right now, 0 (full 3D) to 1 (flat).

    Declaration

    Objective-C

    - (float)getFlattenRatio;

    Swift

    func getFlattenRatio() -> Float

    Return Value

    The flatten ratio.

  • Drives the 2D/3D switch by hand, off the app’s own clock: 0 is full 3D, 1 is flat. Writing this takes the ratio away from setFlattened’s animation, which is what an app does to make the terrain match a camera flight EXACTLY - feed it the flight’s own progress rather than hope two timers agree. Auto-flattening is suspended while the app drives, and STAYS suspended until setFlattened hands the ratio back - so an app that drives an animation writes setFlattened once at the end of it, or a later tilt gesture does nothing.

    Rising is still gated on the tiles 3D needs: a ratio below 1 asks for them and the ground is HELD flat until they arrive, because unsubdivided geometry displaced over relief is a road in the sky. isSwitching() is that hold - wait on it before starting the animation.

    Declaration

    Objective-C

    - (void)setFlattenRatio:(float)ratio;

    Swift

    func setFlattenRatio(_ ratio: Float)

    Parameters

    ratio

    The new flatten ratio, 0 to 1.

  • Returns whether the switch is holding the ground flat while the tiles 3D needs load.

    Declaration

    Objective-C

    - (BOOL)isSwitching;

    Swift

    func isSwitching() -> Bool

    Return Value

    True while the switch is waiting for tiles.

  • Returns the screen parallax below which the terrain renders flat.

    Declaration

    Objective-C

    - (float)getAutoFlattenParallax;

    Swift

    func getAutoFlattenParallax() -> Float

    Return Value

    The parallax in screen pixels. The default is 2. 0 never flattens.

  • Sets the terrain parallax, in SCREEN PIXELS, below which 3D stops being worth its cost and the map renders flat. The parallax is how far the highest ground in view moves on screen because it is displaced:

    parallax = halfScreenDiagonal * heightRange * exaggeration / cameraDistance
    

    so it falls with the camera’s height and rises with how mountainous the data is - a fixed zoom threshold is wrong for one of the two. The rule writes the same state setFlattened does, without touching setEnabled; how far flattening then goes is setFlattenMode. Restores at 1.5x this value, so a camera sitting on the boundary does not oscillate.

    Declaration

    Objective-C

    - (void)setAutoFlattenParallax:(float)pixels;

    Swift

    func setAutoFlattenParallax(_ pixels: Float)

    Parameters

    pixels

    The new parallax threshold in screen pixels, or 0 to never flatten. The default is 2.

  • Returns the tilt at or above which the terrain renders flat.

    Declaration

    Objective-C

    - (float)getAutoFlattenTilt;

    Swift

    func getAutoFlattenTilt() -> Float

    Return Value

    The tilt in degrees. The default is 88. 0 never flattens.

  • Sets the tilt, in degrees, at or above which the map renders flat whatever the parallax. 90 is straight down in this SDK, where the displacement is there but shows nothing worth its cost. Restores 2 degrees below the threshold, so a tilt gesture does not oscillate.

    Declaration

    Objective-C

    - (void)setAutoFlattenTilt:(float)tilt;

    Swift

    func setAutoFlattenTilt(_ tilt: Float)

    Parameters

    tilt

    The new tilt threshold in degrees, or 0 to never flatten. The default is 88.

  • Returns how long the terrain takes to sink flat.

    Declaration

    Objective-C

    - (float)getAutoFlattenDuration;

    Swift

    func getAutoFlattenDuration() -> Float

    Return Value

    The duration in seconds. The default is 0.3.

  • Sets how long the terrain takes to sink flat, and - unless setAutoFlattenRiseDuration overrides it - to rise again. The ramp scales the heights on the GPU, so it costs no tile re-decode; only when it reaches flat are the terrain passes themselves dropped, by which point the two render identically. Does not cover the wait for the tiles 3D needs (see setFlattenMode) - that is not the animation.

    Declaration

    Objective-C

    - (void)setAutoFlattenDuration:(float)duration;

    Swift

    func setAutoFlattenDuration(_ duration: Float)

    Parameters

    duration

    The new duration in seconds. 0 switches instantly.

  • Returns how long the terrain takes to rise back into 3D.

    Declaration

    Objective-C

    - (float)getAutoFlattenRiseDuration;

    Swift

    func getAutoFlattenRiseDuration() -> Float

    Return Value

    The duration in seconds, or a negative value to follow getAutoFlattenDuration.

  • Sets how long the terrain takes to RISE, separately from how long it takes to sink. The two are rarely worth the same: the rise is the one an app matches to a camera flight, and the one that waited for its tiles first. For an exact match to a flight, drive setFlattenRatio instead - a duration is a second timer, not the same clock.

    Declaration

    Objective-C

    - (void)setAutoFlattenRiseDuration:(float)duration;

    Swift

    func setAutoFlattenRiseDuration(_ duration: Float)

    Parameters

    duration

    The new duration in seconds, or a negative value to use setAutoFlattenDuration.

  • Returns the terrain height exaggeration factor.

    Declaration

    Objective-C

    - (float)getExaggeration;

    Swift

    func getExaggeration() -> Float

    Return Value

    The exaggeration factor. The default is 1.0.

  • Sets the terrain height exaggeration factor. 1.0 means true-to-scale heights. Note: changing the exaggeration triggers a re-tesselation of loaded tiles, which is a relatively expensive operation.

    Declaration

    Objective-C

    - (void)setExaggeration:(float)exaggeration;

    Swift

    func setExaggeration(_ exaggeration: Float)

    Parameters

    exaggeration

    The new exaggeration factor.

  • Returns whether seamless tile edge handling is enabled.

    Declaration

    Objective-C

    - (BOOL)isSeamlessTileEdgesEnabled;

    Swift

    func isSeamlessTileEdgesEnabled() -> Bool

    Return Value

    True if elevation textures take their border texels from neighbouring DEM tiles at any level. The default is true.

  • Enables or disables seamless tile edge handling. When enabled, the 1-texel border of every elevation texture is taken from the neighbouring elevation tiles - same-level neighbours texel-exactly, coarser (ancestor) neighbours by sampling their height field. Adjacent terrain tiles then agree on the height along their shared edge instead of showing a ridge of up to one DEM texel of relief. Costs no IO, only a small amount of CPU when an elevation texture is built. Disable if the elevation tiles already match exactly across tile borders.

    Declaration

    Objective-C

    - (void)setSeamlessTileEdgesEnabled:(BOOL)enabled;

    Swift

    func setSeamlessTileEdgesEnabled(_ enabled: Bool)

    Parameters

    enabled

    True to fill elevation texture borders from neighbouring tiles.

  • Returns whether elevation tile prefetching is enabled.

    Declaration

    Objective-C

    - (BOOL)isElevationPrefetchEnabled;

    Swift

    func isElevationPrefetchEnabled() -> Bool

    Return Value

    True if visible tiles and their neighbours are requested from the elevation data source. The default is true.

  • Enables or disables elevation tile prefetching. When enabled, every visible terrain tile asynchronously requests its own elevation tile and the 8 surrounding ones, so neighbouring terrain tiles are displaced by the same DEM level and border texels have real neighbour data. When disabled, elevation tiles are only loaded as a side effect of map tile fetches, which leaves cached map tiles (and the tiles around the viewport) on coarser ancestor elevation data. This is the costly option: it adds elevation tile requests, decoding and cache pressure. Disable to keep elevation traffic at a minimum, or if the elevation tileset is fully local.

    Declaration

    Objective-C

    - (void)setElevationPrefetchEnabled:(BOOL)enabled;

    Swift

    func setElevationPrefetchEnabled(_ enabled: Bool)

    Parameters

    enabled

    True to prefetch elevation tiles for visible tiles and their neighbours.

  • Returns the terrain mesh resolution.

    Declaration

    Objective-C

    - (int)getMeshResolution;

    Swift

    func getMeshResolution() -> Int32

    Return Value

    The maximum number of grid cells per tile edge used for terrain geometry. The default is 64.

  • Sets the terrain mesh resolution. Higher values give more detailed terrain at the cost of memory and CPU. The effective resolution is also limited by the resolution of the elevation tiles.

    Declaration

    Objective-C

    - (void)setMeshResolution:(int)meshResolution;

    Swift

    func setMeshResolution(_ meshResolution: Int32)

    Parameters

    meshResolution

    The new mesh resolution (clamped to 2..256).

  • Returns whether cross-LOD tile edge stitching is enabled.

    Declaration

    Objective-C

    - (BOOL)isTileEdgeStitchingEnabled;

    Swift

    func isTileEdgeStitchingEnabled() -> Bool

    Return Value

    True if grid surface edges follow a coarser neighbour’s lattice. The default is true.

  • Enables or disables cross-LOD tile edge stitching. Neighbouring terrain tiles at different zoom levels interpolate the elevation between differently spaced grid vertices along their shared edge, which opens a thin crack. When enabled, the finer tile chords across the coarser neighbour’s grid nodes on that edge, so both tiles describe the same edge. Needs an even MeshResolution, and only takes effect in GPU draping mode. Costs one uniform per tile - no extra geometry.

    Declaration

    Objective-C

    - (void)setTileEdgeStitchingEnabled:(BOOL)enabled;

    Swift

    func setTileEdgeStitchingEnabled(_ enabled: Bool)

    Parameters

    enabled

    True to snap grid surface edges to a coarser neighbour’s grid.

  • Returns whether polygon fills are draped as a render-to-texture surface.

    Declaration

    Objective-C

    - (BOOL)isDrapeFillsEnabled;

    Swift

    func isDrapeFillsEnabled() -> Bool

    Return Value

    True if fills are baked to a per-tile texture and sampled on the surface. The default is false.

  • Enables or disables maplibre-style render-to-texture fill draping (experimental, spike). When enabled, polygon fills are rendered FLAT into a per-tile offscreen texture and then sampled as the color of the terrain surface mesh, instead of being drawn as displaced geometry. Because the fills become the surface’s texture they follow the terrain exactly - no chord sag, so no holes, no see-through, and no depth slack - at flat-render (2D) fill cost. Lines/contours and labels are unaffected (still drawn as sharp geometry on top). Only native (non-overzoomed) fills are draped. Requires GPU draping mode (vertex texture fetch, planar projection).

    Declaration

    Objective-C

    - (void)setDrapeFillsEnabled:(BOOL)enabled;

    Swift

    func setDrapeFillsEnabled(_ enabled: Bool)

    Parameters

    enabled

    True to drape fills as a texture, false to draw them as geometry.

  • Returns whether vt tile lines are also draped (in addition to fills).

    Declaration

    Objective-C

    - (BOOL)isDrapeLinesEnabled;

    Swift

    func isDrapeLinesEnabled() -> Bool

    Return Value

    True if tile lines are baked into the drape texture. The default is true.

  • Enables or disables draping of vt tile lines in addition to fills (needs DrapeFillsEnabled). Draped lines are baked into the per-tile texture: they follow the terrain exactly and cost no per-frame geometry (a city pan runs at twice the frame rate), but they resolve at the drape resolution rather than the screen’s. Layers matching NoDrapeLayerFilter stay sharp either way. See docs/internals/rendering/04-terrain.md.

    Declaration

    Objective-C

    - (void)setDrapeLinesEnabled:(BOOL)enabled;

    Swift

    func setDrapeLinesEnabled(_ enabled: Bool)

    Parameters

    enabled

    True to drape tile lines too, false to keep them as sharp geometry.

  • Returns whether bridges and tunnels stand on their own chord (3D bridges).

    Declaration

    Objective-C

    - (BOOL)isBridges3DEnabled;

    Swift

    func isBridges3DEnabled() -> Bool

    Return Value

    True if a span feature is lifted onto the chord between its portals and a span deck is drawn as an extrusion. The default is false.

  • Enables or disables 3D bridges: a feature styled line-elevation-mode: span (or the polygon/building variants) is laid straight between its two portals instead of draped over the terrain, and a span deck stands as an extrusion carrying its road. Off, every such feature drapes like the ground and none of the span machinery runs - no chord resolution, no deck drape bakes, no reference tile fetches. Needs terrain. See docs/internals/rendering/04-terrain.md, “Bridges and tunnels: spans”.

    Declaration

    Objective-C

    - (void)setBridges3DEnabled:(BOOL)enabled;

    Swift

    func setBridges3DEnabled(_ enabled: Bool)

    Parameters

    enabled

    True to lift spans onto their chord, false to drape them.

  • Returns the style layers that are kept out of the terrain drape bake.

    Declaration

    Objective-C

    - (NSString *)getNoDrapeLayerFilter;

    Swift

    func getNoDrapeLayerFilter() -> String!

    Return Value

    A regular expression matched against vt style layer names. The default is “^contour.*”; an empty string drapes everything the geometry type allows.

  • Sets which style layers must NOT be baked into the drape texture, as a regular expression over the vt layer name (which comes from the style’s own rule names). They are drawn live in the 3D pass at screen resolution instead. Hairline content is what the drape resolution costs, hence contours by default. They still take the terrain’s sun and shadow, so they shade like the ground they lie on.

    Declaration

    Objective-C

    - (void)setNoDrapeLayerFilter:(NSString *)filter;

    Swift

    func setNoDrapeLayerFilter(_ filter: String!)

    Parameters

    filter

    The regular expression, or an empty string to drape everything.

  • Returns the per-tile drape texture resolution, 0 when it follows the screen.

    Declaration

    Objective-C

    - (int)getDrapeResolution;

    Swift

    func getDrapeResolution() -> Int32

    Return Value

    The drape texture resolution in pixels, 0 for automatic.

  • Sets the per-tile drape texture resolution. Draped content is rasterized into a texture of this size and resampled onto the terrain surface, so this trades sharpness of thin content (lines, outlines) against video memory: cost is resolution^2 * 4 bytes per visible tile. maplibre uses twice the tile size (1024 for 512px tiles) for this reason. 0 (the default) takes it from the SCREEN instead: the tile LOD refines a tile until it covers at most a 2x2 block of nominal tiles, so 2 * tileDrawSize * pixelScale texels is one texel per screen pixel at that bound - a fixed resolution is either coarser than the screen (draped fill edges stair-step as you zoom in) or finer than it can show.

    Declaration

    Objective-C

    - (void)setDrapeResolution:(int)resolution;

    Swift

    func setDrapeResolution(_ resolution: Int32)

    Parameters

    resolution

    The new drape texture resolution, clamped to [128, 2048], or 0 to follow the screen.

  • Returns the minimum tile zoom level with 3D terrain.

    Declaration

    Objective-C

    - (int)getMinZoom;

    Swift

    func getMinZoom() -> Int32

    Return Value

    The minimum zoom level. The default is 5.

  • Sets the minimum tile zoom level with 3D terrain. Tiles below this zoom level render flat and do not fetch elevation data. Terrain displacement is invisible at low zoom levels anyway, so this limits the number of elevation tiles fetched and processed for far-away/zoomed-out views.

    Declaration

    Objective-C

    - (void)setMinZoom:(int)minZoom;

    Swift

    func setMinZoom(_ minZoom: Int32)

    Parameters

    minZoom

    The new minimum zoom level (clamped to 0..24).

  • Returns the factor applied to the view distance.

    Declaration

    Objective-C

    - (float)getViewDistanceFactor;

    Swift

    func getViewDistanceFactor() -> Float

    Return Value

    The view distance factor. The default is 1, which is exactly tangram’s rule.

  • Sets how far from the camera the map is drawn and where the far plane sits, as a factor on tangram’s own rule (core/src/view/view.cpp): far = 2 * cameraHeight / cos(pitch + fovy/2), capped by maxTileDistance = worldTileSize(zoom) * (2^(MAX_LOD+1) - 1), with MAX_LOD 6. A factor of 1 is that rule verbatim; smaller ends the view closer, larger extends it. This is what makes a near-horizontal view affordable: taken from the visible ground instead, the view reaches the horizon - hundreds of tiles, most of them a few pixels tall, each carrying its own labels. Pair a small factor with fog so the ground fades out instead of ending. It also decides the depth budget: tangram’s model is calibrated on a far/near ratio of a few hundred, and a deeper far spends the NDC precision the per-layer depth separation needs. A style may pin an absolute distance instead, in meters, with “terrain-max-visible-distance”.

    Declaration

    Objective-C

    - (void)setViewDistanceFactor:(float)factor;

    Swift

    func setViewDistanceFactor(_ factor: Float)

    Parameters

    factor

    The new view distance factor. The default is 1.

  • Returns the minimum view distance, in meters.

    Declaration

    Objective-C

    - (float)getViewDistance;

    Swift

    func getViewDistance() -> Float

    Return Value

    The view distance in meters. 0 (the default) leaves the factor rule alone.

  • Sets a MINIMUM distance the map is drawn to, in METERS, whatever the camera’s height or pitch. Tangram’s rule is proportional to the camera’s height above the ground, so approaching the terrain shortens the view - which is right for a map seen from above and wrong for a view along the ground, where the same landscape should stay visible as the camera descends into it. An absolute distance keeps the ground reaching at least this far at any elevation and any tilt. The far plane follows it, which spends depth precision (see setViewDistanceFactor), so this is an explicit trade - pair it with fog so the ground fades out instead of ending. It only ever EXTENDS the factor rule: metres are zoom-independent while the rule scales with the camera’s height, so a distance that reaches the horizon up close would end the ground in a disc well inside a zoomed-out screen. 0 (the default) leaves the factor rule alone.

    Declaration

    Objective-C

    - (void)setViewDistance:(float)distance;

    Swift

    func setViewDistance(_ distance: Float)

    Parameters

    distance

    The new minimum view distance in meters, or 0 for the factor rule alone.

  • Returns the drape cache budget in megabytes.

    Declaration

    Objective-C

    - (int)getDrapeCacheSize;

    Swift

    func getDrapeCacheSize() -> Int32

    Return Value

    The drape cache budget in megabytes. The default is 96.

  • Sets how much video memory the cached drape textures may take, in megabytes. The cache has to hold the LIVE cover AND the generation it just replaced: a leaf whose own bake has not landed stands in on the cached tiles under it, so a budget that fits only one cover evicts the previous generation on every frame of a zoom and those leaves are painted in the flat background colour instead - the ground blinking during a fast zoom. It also decides the automatic drape resolution (see DrapeResolution and DrapeWorkingSet), since the two have to agree.

    Declaration

    Objective-C

    - (void)setDrapeCacheSize:(int)megabytes;

    Swift

    func setDrapeCacheSize(_ megabytes: Int32)

    Parameters

    megabytes

    The new budget in megabytes, or 0 for the default of 96.

  • Returns how many drape tiles the automatic resolution assumes are cached at once.

    Declaration

    Objective-C

    - (int)getDrapeWorkingSet;

    Swift

    func getDrapeWorkingSet() -> Int32

    Return Value

    The assumed working set in tiles. The default is 64.

  • Sets how many drape tiles the automatic resolution (DrapeResolution 0) assumes have to fit the budget at once: the live cover plus the generation a zoom or pan is about to need back. The resolution is halved until that many fit DrapeCacheSize. Lower values buy sharpness at the price of a cache that thrashes; a real cover was measured at 15-34 leaves, so a working set below that cannot hold even the live cover.

    Declaration

    Objective-C

    - (void)setDrapeWorkingSet:(int)tiles;

    Swift

    func setDrapeWorkingSet(_ tiles: Int32)

    Parameters

    tiles

    The assumed working set in tiles. The default is 64.

  • Returns how many zoom levels below the camera a tile may coarsen to.

    Declaration

    Objective-C

    - (int)getMaxTileZoomCoarsening;

    Swift

    func getMaxTileZoomCoarsening() -> Int32

    Return Value

    The maximum tile zoom coarsening. The default is 3.

  • Sets how far BELOW the camera’s zoom the tile LOD may take a tile in terrain mode (Options::TileLODFactor decides the rest). The tile surface is the depth OCCLUDER and its tesselation is proportional to the tile size, so a tile that coarsens freely has its ridge crests chopped flat and content drawn over a finer tile of another layer - a road, a contour - shows through the ridge in front of it. The DEM level follows the tile zoom as well (one elevation texture per tile), so the same tiles also shade as blocky hillshade. Larger values give the LOD more room - fewer tiles at a tilt, at the price of both; 0 pins every tile to the camera’s own zoom.

    Declaration

    Objective-C

    - (void)setMaxTileZoomCoarsening:(int)levels;

    Swift

    func setMaxTileZoomCoarsening(_ levels: Int32)

    Parameters

    levels

    The new maximum tile zoom coarsening. The default is 3.

  • Returns the terrain background color.

    Declaration

    Objective-C

    - (MSFColor *)getBackgroundColor;

    Swift

    func getBackgroundColor() -> MSFColor!

    Return Value

    The terrain background color. The default is transparent (no background).

  • Sets the terrain background color: an opaque base fill of the terrain surface drawn under all layers. It keeps the terrain shape visible (and its depth valid for vector element and billboard occlusion) even without any raster or vector tile layer content - without it the terrain is transparent wherever no layer paints. Transparent (the default) disables the fill.

    Declaration

    Objective-C

    - (void)setBackgroundColor:(MSFColor *)color;

    Swift

    func setBackgroundColor(_ color: MSFColor!)

    Parameters

    color

    The new terrain background color.

  • Returns the terrain background bitmap state.

    Declaration

    Objective-C

    - (BOOL)isBackgroundBitmapEnabled;

    Swift

    func isBackgroundBitmapEnabled() -> Bool

    Return Value

    True if the map background bitmap is draped over the terrain as the base fill. The default is false.

  • Sets the terrain background bitmap state. When enabled, the map background bitmap (Options::getBackgroundBitmap, the repeating pattern flat maps show below the tiles) is draped over the terrain surface as the base fill drawn under all layers, instead of the solid background color. Like the background color fill, it keeps the terrain shape visible (and its depth valid for occlusion) where no layer paints, and shows through translucent tile layer content.

    Declaration

    Objective-C

    - (void)setBackgroundBitmapEnabled:(BOOL)enabled;

    Swift

    func setBackgroundBitmapEnabled(_ enabled: Bool)

    Parameters

    enabled

    The new background bitmap state.

  • Returns the custom terrain surface fragment shader source, or an empty string if no shaded surface is drawn.

    Declaration

    Objective-C

    - (NSString *)getSurfaceShaderSource;

    Swift

    func getSurfaceShaderSource() -> String!

    Return Value

    The custom surface shader source.

  • Sets a fragment shader that paints the terrain surface itself. When set, it replaces the background bitmap and the background color as the terrain base fill: the surface is drawn as an opaque pass under all layers, so a map with no tile layer at all still shows shaded relief. The source must define

    vec4 surfaceColor();
    

    returning the non-premultiplied surface colour. These are available to it:

    varying vec3  v_normal;      // unit surface normal, world space (x east, y north, z up)
    varying vec3  v_worldPos;    // surface position in internal map units
    varying float v_elevation;   // surface elevation in metres (before exaggeration)
    varying float v_dist;        // distance from the camera in metres
    uniform vec3  u_sunDir;      // unit vector towards the sun, world space
    uniform vec4  u_sunColor;    // sun colour, rgba 0..1
    uniform float u_sunIntensity;
    uniform float u_ambientIntensity;
    uniform float u_time;        // seconds since the map view was created
    uniform float u_zoom;        // current fractional map zoom
    uniform vec2  u_resolution;  // viewport size in pixels
    

    The surface must NOT fog itself: the SDK applies the same fog the rest of the frame gets to whatever this returns. The fog uniforms and helpers documented on FogOptions::setShaderSource are declared here too, and must not be redeclared.

    plus every parameter set with setSurfaceParameter (float) and setSurfaceColorParameter (vec4, rgba 0..1) as a uniform of that name. Redeclaring any of the above is a compile error, and a shader that fails to compile is dropped (the background bitmap/color is used instead) with the error logged.

    Declaration

    Objective-C

    - (void)setSurfaceShaderSource:(NSString *)shaderSource;

    Swift

    func setSurfaceShaderSource(_ shaderSource: String!)

    Parameters

    shaderSource

    The GLSL source, or an empty string for no shaded surface.

  • Returns the value of a terrain surface shader float parameter.

    Declaration

    Objective-C

    - (float)getSurfaceParameter:(NSString *)name;

    Swift

    func getSurfaceParameter(_ name: String!) -> Float

    Parameters

    name

    The name of the parameter.

    Return Value

    The value of the parameter, or 0 if not set.

  • Sets a terrain surface shader float parameter, exposed to the shader as a uniform.

    Declaration

    Objective-C

    - (void)setSurfaceParameter:(NSString *)name value:(float)value;

    Swift

    func setSurfaceParameter(_ name: String!, value: Float)

    Parameters

    name

    The name of the parameter (must be a valid GLSL identifier).

    value

    The new value for the parameter.

  • Returns the value of a terrain surface shader color parameter.

    Declaration

    Objective-C

    - (MSFColor *)getSurfaceColorParameter:(NSString *)name;

    Swift

    func getSurfaceColorParameter(_ name: String!) -> MSFColor!

    Parameters

    name

    The name of the parameter.

    Return Value

    The value of the parameter, or transparent black if not set.

  • Sets a terrain surface shader color parameter, exposed to the shader as a vec4 uniform with components in the 0..1 range.

    Declaration

    Objective-C

    - (void)setSurfaceColorParameter:(NSString *)name color:(MSFColor *)color;

    Swift

    func setSurfaceColorParameter(_ name: String!, color: MSFColor!)

    Parameters

    name

    The name of the parameter (must be a valid GLSL identifier).

    color

    The new value for the parameter.

  • Returns the maximum visible tile zoom offset, relative to the camera zoom level.

    Declaration

    Objective-C

    - (int)getMaxTileZoomOffset;

    Swift

    func getMaxTileZoomOffset() -> Int32

    Return Value

    The maximum tile zoom offset. The default is 100 (no cap).

  • Sets the maximum visible tile zoom offset, relative to the camera zoom level. Terrain level-of-detail is distance based: tiles close to the camera (and mountain faces rising towards it) are shown at higher tile zoom levels than flat rendering would ever use at the same camera zoom. If the map style renders differently at different tile zoom levels, these LOD rings become visible as patches with hard boundaries. Offset 0 caps tile detail at the level flat rendering would show at the current camera zoom; positive values allow that many extra levels of detail near the camera. Values of 100 or more disable the cap.

    Declaration

    Objective-C

    - (void)setMaxTileZoomOffset:(int)offset;

    Swift

    func setMaxTileZoomOffset(_ offset: Int32)

    Parameters

    offset

    The new maximum tile zoom offset (values >= 100 disable the cap).

  • Returns the camera terrain clearance floor: an explicit minimum height the camera is kept above the terrain surface, in meters.

    Declaration

    Objective-C

    - (float)getCameraClearance;

    Swift

    func getCameraClearance() -> Float

    Return Value

    The camera clearance floor in meters. The default is 0.

  • Sets the camera terrain clearance floor, in meters. The camera is always kept a height above the terrain under it that scales with the zoom, as in mapbox: a sixteenth of its distance to sea level, so zooming in is never blocked by the clearance alone. This floor is added under that rule for apps that want a fixed minimum. A zoom in stops at the clearance; a camera pushed under it by a pan or by arriving elevation is lifted at a constant zoom, by reducing the tilt.

    Declaration

    Objective-C

    - (void)setCameraClearance:(float)clearance;

    Swift

    func setCameraClearance(_ clearance: Float)

    Parameters

    clearance

    The new clearance floor in meters. 0 (the default) applies the zoom-relative rule alone.

  • Returns the duration of the camera terrain-following correction animation.

    Declaration

    Objective-C

    - (float)getCameraClampDuration;

    Swift

    func getCameraClampDuration() -> Float

    Return Value

    The correction duration in seconds. The default is 0 (instant correction).

  • Sets the duration of the camera terrain-following correction animation.

    Declaration

    Objective-C

    - (void)setCameraClampDuration:(float)duration;

    Swift

    func setCameraClampDuration(_ duration: Float)

    Parameters

    duration

    The new duration in seconds. 0 applies corrections instantly.

  • Returns the clip-space depth bias used when depth-testing draped 2D geometry against the terrain.

    Declaration

    Objective-C

    - (float)getDepthBias;

    Swift

    func getDepthBias() -> Float

    Return Value

    The depth bias. The default is 0.0002.

  • Sets the clip-space depth bias used when depth-testing draped 2D geometry against the terrain. Larger values prevent draped layers from being clipped by the terrain surface itself, at the cost of geometry slightly behind terrain ridges ‘shining through’ near silhouettes.

    Declaration

    Objective-C

    - (void)setDepthBias:(float)depthBias;

    Swift

    func setDepthBias(_ depthBias: Float)

    Parameters

    depthBias

    The new depth bias (clamped to 0..0.01).

  • Returns the billboard/label terrain occlusion tolerance.

    Declaration

    Objective-C

    - (float)getBillboardOcclusionTolerance;

    Swift

    func getBillboardOcclusionTolerance() -> Float

    Return Value

    The relative depth tolerance. The default is 0.

  • Sets how far behind the terrain a billboard or label anchor may sit and still count as visible, as a fraction of its distance from the camera. 0, the default, hides a label the moment its anchor goes behind the relief. Larger values deliberately let partly hidden features label - a summit just behind a nearer ridge still shows its name, which is what a peak-finder view wants.

    Declaration

    Objective-C

    - (void)setBillboardOcclusionTolerance:(float)tolerance;

    Swift

    func setBillboardOcclusionTolerance(_ tolerance: Float)

    Parameters

    tolerance

    The new relative tolerance (clamped to 0..1).

  • Returns the opacity a label keeps while its anchor is behind 3D content.

    Declaration

    Objective-C

    - (float)getTextOcclusionOpacity;

    Swift

    func getTextOcclusionOpacity() -> Float

    Return Value

    The opacity of an occluded label. The default is 1, i.e. no occlusion.

  • Sets the opacity a label keeps while the point it is anchored at is hidden by 3D content - buildings, not the terrain, which occludes labels regardless (see BillboardOcclusionTolerance). 0 hides such a label completely; 1, the default, draws it as if nothing were in front of it.

    The test is per LABEL, not per fragment: a building crossing part of a word does not cut it, the whole label fades by how much of a small square around its anchor is covered.

    Below 1 this costs one extra pass over the visible extrusions per frame (measured at ~0.85 ms on an Adreno 610 at a city camera); at 1 the pass does not run at all. The style’s ‘text-occlusion-opacity’ wins over this value where it sets one.

    Declaration

    Objective-C

    - (void)setTextOcclusionOpacity:(float)opacity;

    Swift

    func setTextOcclusionOpacity(_ opacity: Float)

    Parameters

    opacity

    The opacity of an occluded label (clamped to 0..1).

  • Returns the billboard/label terrain occlusion state.

    Declaration

    Objective-C

    - (BOOL)isBillboardOcclusionEnabled;

    Swift

    func isBillboardOcclusionEnabled() -> Bool

    Return Value

    True if billboards and labels hidden behind terrain are faded out. The default is true.

  • Sets the billboard/label terrain occlusion state.

    Declaration

    Objective-C

    - (void)setBillboardOcclusionEnabled:(BOOL)enabled;

    Swift

    func setBillboardOcclusionEnabled(_ enabled: Bool)

    Parameters

    enabled

    The new occlusion state.

  • Returns the terrain elevation in meters at the given position. The position is expected to be in WGS84 coordinates. Note: this method may block on network/IO if the elevation tile is not cached.

    Declaration

    Objective-C

    - (double)getElevation:(MSFMapPos *)pos;

    Swift

    func getElevation(_ pos: MSFMapPos!) -> Double

    Parameters

    pos

    The position to query.

    Return Value

    The elevation in meters, or -1000000 if no elevation data is available.

  • Returns terrain elevations in meters at the given positions (WGS84). One value is returned for every input position, in the input order. Note: this method may block on network/IO if the elevation tiles are not cached.

    Declaration

    Objective-C

    - (MSFDoubleVector *)getElevations:(MSFMapPosVector *)poses;

    Swift

    func getElevations(_ poses: MSFMapPosVector!) -> MSFDoubleVector!

    Parameters

    poses

    The positions to query.

    Return Value

    The elevations in meters (-1000000 where no data is available).

  • Undocumented

    Declaration

    Objective-C

    -(void)dealloc;

    Swift

    func dealloc()