-
The
styleobject supports run time styling.Declaration
Swift
public internal(set) var style: Style { get }
-
Loads a style from a StyleURI, calling a completion closure when the style is fully loaded or there has been an error during load.
Declaration
Parameters
styleURIStyleURI to load
completionClosure called when the style has been fully loaded. The
Resulttype encapsulates theStyleor error that occurred. SeeMapLoadingError -
Loads a style from a JSON string, calling a completion closure when the style is fully loaded or there has been an error during load.
Declaration
Swift
public func loadStyleJSON(_ JSON: String, completion: ((Result<Style, Error>) -> Void)? = nil)Parameters
styleURIStyle JSON string
completionClosure called when the style has been fully loaded. The
Resulttype encapsulates theStyleor error that occurred. SeeMapLoadingError
-
When loading a map, if
prefetchZoomDeltais set to any number greater than 0, the map will first request a tile forzoom - prefetchZoomDeltain an 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.
Declaration
Swift
public var prefetchZoomDelta: UInt8 { get set } -
Gets the resource options for the map.
All optional fields of the returned object are initialized with the actual values.
Note
The result of this property is different from theResourceOptionsthat were provided to the map’s initializer.Declaration
Swift
public var resourceOptions: ResourceOptions { get } -
Clears temporary map data.
Clears temporary map data from the data path defined in the given resource options. Useful to reduce the disk usage or in case the disk cache contains invalid data.
Note
Calling this API will affect all maps that use the same data path and does not affect persistent map data like offline style packages.
Declaration
Swift
public static func clearData(for resourceOptions: ResourceOptions, completion: @escaping (Error?) -> Void)Parameters
resourceOptionsThe
resource optionsthat contain the map data path to be usedcompletionCalled once the request is complete
-
Gets elevation for the given coordinate.
Note
Elevation is only available for the visible region on the screen.
Declaration
Swift
public func elevation(at coordinate: CLLocationCoordinate2D) -> Double?Parameters
coordinateCoordinate for which to return the elevation.
Return Value
Elevation (in meters) multiplied by current terrain exaggeration, or empty if elevation for the coordinate is not available.
-
Transforms a view’s frame into a set of coordinate bounds
Declaration
Swift
public func coordinateBounds(for rect: CGRect) -> CoordinateBoundsParameters
rectThe
rectwhose bounds will be transformed into a set of map coordinate bounds.Return Value
A
CoordinateBoundsobject that represents the southwest and northeast corners of the view’s bounds. -
Transforms a set of map coordinate bounds to a
CGRectrelative to theMapView.Declaration
Swift
public func rect(for coordinateBounds: CoordinateBounds) -> CGRectParameters
coordinateBoundsThe
coordinateBoundsthat will be converted into a rect relative to theMapViewReturn Value
A
CGRectwhose corners represent the vertices of a set ofCoordinateBounds. -
Declaration
Swift
public var options: MapOptions { get }
-
Declaration
Swift
public func camera(for coordinateBounds: CoordinateBounds, padding: UIEdgeInsets, bearing: Double?, pitch: Double?) -> CameraOptions -
Declaration
Swift
public func camera(for coordinates: [CLLocationCoordinate2D], padding: UIEdgeInsets, bearing: Double?, pitch: Double?) -> CameraOptions -
Declaration
Swift
public func camera(for coordinates: [CLLocationCoordinate2D], camera: CameraOptions, rect: CGRect) -> CameraOptions -
Declaration
Swift
public func camera(for geometry: Turf.Geometry, padding: UIEdgeInsets, bearing: CGFloat?, pitch: CGFloat?) -> CameraOptions
-
Declaration
Swift
public func coordinateBounds(for camera: CameraOptions) -> CoordinateBounds -
Declaration
Swift
public func coordinateBoundsZoom(for camera: CameraOptions) -> CoordinateBoundsZoom -
Declaration
Swift
public func coordinateBoundsZoomUnwrapped(for camera: CameraOptions) -> CoordinateBoundsZoom -
Declaration
Swift
public func coordinate(for point: CGPoint) -> CLLocationCoordinate2D -
Declaration
Swift
public func point(for coordinate: CLLocationCoordinate2D) -> CGPoint -
Declaration
Swift
public func points(for coordinates: [CLLocationCoordinate2D]) -> [CGPoint] -
Declaration
Swift
public func coordinates(for points: [CGPoint]) -> [CLLocationCoordinate2D]
-
Declaration
Swift
public func setCamera(to cameraOptions: CameraOptions) -
Declaration
Swift
public var cameraState: CameraState { get } -
Declaration
Swift
public var freeCameraOptions: FreeCameraOptions { get set } -
Returns the bounds of the map.
Declaration
Swift
public var cameraBounds: CameraBounds { get } -
Sets the bounds of the map.
Throws
MapErrorDeclaration
Swift
public func setCameraBounds(for options: CameraBoundsOptions) throwsParameters
optionsNew camera bounds. Nil values will not take effect.
-
Declaration
Swift
public func dragStart(for point: CGPoint) -
Declaration
Swift
public func dragCameraOptions(from: CGPoint, to: CGPoint) -> CameraOptions -
Declaration
Swift
public func dragEnd()
-
Declaration
Swift
public func queryRenderedFeatures(for shape: [CGPoint], options: RenderedQueryOptions? = nil, completion: @escaping (Result<[QueriedFeature], Error>) -> Void) -
Declaration
Swift
public func queryRenderedFeatures(in rect: CGRect, options: RenderedQueryOptions? = nil, completion: @escaping (Result<[QueriedFeature], Error>) -> Void) -
Declaration
Swift
public func queryRenderedFeatures(at point: CGPoint, options: RenderedQueryOptions? = nil, completion: @escaping (Result<[QueriedFeature], Error>) -> Void) -
Declaration
Swift
public func querySourceFeatures(for sourceId: String, options: SourceQueryOptions, completion: @escaping (Result<[QueriedFeature], Error>) -> Void) -
Declaration
Swift
public func queryFeatureExtension(for sourceId: String, feature: Turf.Feature, extension: String, extensionField: String, args: [String: Any]? = nil, completion: @escaping (Result<FeatureExtensionValue, Error>) -> Void)
-
Declaration
Swift
public func subscribe(_ observer: Observer, events: [String]) -
Declaration
Swift
public func unsubscribe(_ observer: Observer, events: [String] = [])
-
Declaration
Swift
@discardableResult public func onNext(_ eventType: MapEvents.EventKind, handler: @escaping (Event) -> Void) -> Cancelable -
Declaration
Swift
@discardableResult public func onEvery(_ eventType: MapEvents.EventKind, handler: @escaping (Event) -> Void) -> Cancelable
-
Clears temporary map data.
Clears temporary map data from the data path defined in the given resource options. Useful to reduce the disk usage or in case the disk cache contains invalid data.
Note
Calling this API will affect all maps that use the same data path and does not affect persistent map data like offline style packages.
Declaration
Swift
public func clearData(completion: @escaping (Error?) -> Void)Parameters
completionCalled once the request is complete
MapboxMap Class Reference