MTGeoJSONSource
public class MTGeoJSONSource : MTSource, @unchecked Sendable, Codable
A geojson source.
-
Unique id of the source.
Declaration
Swift
public var identifier: String
-
URL pointing to the geojson resource.
Declaration
Swift
public var url: URL?
-
Type of the source.
Declaration
Swift
public private(set) var type: MTSourceType { get }
-
Attribution to be displayed when the map is shown to a user.
Declaration
Swift
public var attribution: String?
-
Size of the tile buffer on each side.
Optional number between 0 and 512 inclusive. 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.
Note
Defaults to 128.Declaration
Swift
public var buffer: Int?
-
If the data is a collection of point features, sets the points by radius into groups.
Note
Defaults to false.Declaration
Swift
public var isCluster: Bool
-
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).
Declaration
Swift
public var clusterMaxZoom: Double?
-
Radius of each cluster if clustering is enabled.
A value of 512 indicates a radius equal to the width of a tile.
Note
Defaults to 50.Declaration
Swift
public var clusterRadius: Double?
-
Maximum zoom level at which to create vector tiles.
Higher value means greater detail at high zoom levels.
Note
Defaults to 18.Declaration
Swift
public var maxZoom: Double?
-
Douglas-Peucker simplification tolerance.
Higher value means simpler geometries and faster performance.
Note
Defaults to 0.375Declaration
Swift
public var tolerance: Double?
-
Specifices whether to calculate line distance metrics
Declaration
Swift
public var lineMetrics: Bool?
-
Initializes the source with unique id and url to TileJSON resource.
Declaration
Swift
public init(identifier: String, url: URL)
-
init(identifier:
url: attribution: buffer: isCluster: clusterMaxZoom: clusterRadius: maxZoom: tolerance: lineMetrics: ) Initializes the source with all the options.
Declaration
Swift
public init( identifier: String, url: URL? = nil, attribution: String? = nil, buffer: Int? = 128, isCluster: Bool = false, clusterMaxZoom: Double? = nil, clusterRadius: Double? = 50, maxZoom: Double? = 18, tolerance: Double? = 0.375, lineMetrics: Bool? = false )
-
Initializes the source from the decoder.
Declaration
Swift
public required init(from decoder: any Decoder) throws
-
Declaration
Swift
public func encode(to encoder: Encoder) throws
-
Sets the data of the source.
Used for updating the source data.
Declaration
Parameters
data
url to GeoJSON resource.
mapView
MTMapView which holds the source.
completionHandler
A handler block to execute when function finishes.
-
setData(data:
Asynchronousin: ) Sets the data of the source.
Used for updating the source data.
Declaration
Swift
@MainActor public func setData(data: URL, in mapView: MTMapView) async
Parameters
data
url to GeoJSON resource.
mapView
MTMapView which holds the source.
-
Adds source to map DSL style.
Prefer
addSource(_:)
on MTMapView instead.Declaration
Swift
public func addToMap(_ mapView: MTMapView)