Other Structures
The following structures are available globally.
-
Options for playback when using
See moreMapRecorder
Declaration
Swift
public struct MapPlayerOptions
-
Options for recording the map when using
See moreMapRecorder
Declaration
Swift
public struct MapRecorderOptions
-
Signal is a typed interface for observing arbitrary values over time.
Signal delegates observers managing logic to the
observeImpl
closure, but provides flexible interface for observing.Note
Signal
is iOS12-compatible simplified alternative toCombine.Publisher
. It’s behavior is aligned with Publisher for easier future migration to Combine. If your app supports iOS >= 13.0, useSignal
asCombine.Publisher
.Declaration
Swift
public struct Signal<Payload>
extension Signal: Combine.Publisher
-
Various options needed for tile cover.
See moreDeclaration
Swift
@_documentation(visibility: public) @_spi(Experimental) public struct TileCoverOptions
-
Enable
os_signpost
generation in some componentsBy default, signpost generation is disabled. It’s possible to enable some components with
status
API.The
MAPBOX_MAPS_SIGNPOSTS_ENABLED
environment variable can be used to manipulate the initial value of the tracing status There are a few rules for environment variable:- The empty value will enable all components tracing. Equals to
enabled
. - The value of
0
ordisabled
will set a default value todisabled
. - All other values will be processed as a component names and be enabled accordingly.
The comma
,
delimiter has to be used to pass multiple components (e.g."core,platform"
). - Value is case-insensitive.
Declaration
Swift
public struct Tracing : OptionSet
- The empty value will enable all components tracing. Equals to
-
Options for enabling debugging features in a map.
See moreDeclaration
Swift
public struct MapViewDebugOptions : OptionSet, Hashable
-
A structure that defines additional information about map content gesture
See moreDeclaration
Swift
public struct MapContentGestureContext
-
The azimuth (orientation) of the user’s device, relative to true or magnetic north.
See moreDeclaration
Swift
public struct Heading : Equatable
-
Represents the interpolated data ready to render the user location puck.
See moreDeclaration
Swift
public struct PuckRenderingData : Equatable
-
A shim that makes it possible to subscribe to
See moreMapboxMap
andSnapshotter
events via the oldonNext
andonEvery
methods. It is here to simplify migration from v10 to v11, but will be removed in v12.Declaration
Swift
@available(*, deprecated) public struct MapEventType<Payload>
-
A style’s fog property is a global effect that improves depth perception by fading out distant objects.
See also
Mapbox Style SpecificationDeclaration
Swift
public struct Atmosphere : Codable
-
Defines scaling mode. Only applies to location-indicator type layers.
See moreDeclaration
Swift
public struct ModelScaleMode : RawRepresentable, Codable, Hashable
-
The name of the projection to be used for rendering the map.
See moreDeclaration
Swift
public struct StyleProjectionName : RawRepresentable, Codable, Hashable
-
Map style configuration.
Use MapStyle with
mapStyle
orMap
(SwiftUI) to load a new style, or update style import configurations.// loads Standard Mapbox Style mapboxMap.mapStyle = .standard // loads Standard Mapbox Style with Dusk light preset mapboxMap.mapStyle = .standard(lightPreset: .dusk) // loads a custom style and updates import configurations for // Mapbox Standard Style imported with "my-import-id" id. mapboxMap.mapStyle = MapStyle( uri: StyleURI(rawValue: "https://example.com/custom-style")! importConfigurations: [ .standard(importId: "my-import-id", lightPreset: .dusk) ])
Every new style update is applied incrementally, so it’s safe to re-set the style if only one configuration parameter is changed.
If StyleURI or Style JSON is not equal to the previous value, the update of the
See moremapStyle
will lead to the style reloading. You can observe result of the style reloading inonStyleLoaded
oronStyleLoaded
events.Declaration
Swift
@_documentation(visibility: public) @_spi(Experimental) public struct MapStyle : Equatable
-
Defines the available light presets in the Mapbox Standard Style.
See moreDeclaration
Swift
@_documentation(visibility: public) @_spi(Experimental) public struct StandardLightPreset : RawRepresentable, Hashable
-
Specifies configuration parameters for style imports.
See moreDeclaration
Swift
@_documentation(visibility: public) @_spi(Experimental) public struct StyleImportConfiguration : Equatable
-
Describes the projection used to render the map.
See moreDeclaration
Swift
public struct StyleProjection : Hashable, Codable
-
Displays a group of circle annotations.
Always prefer to use annotation group over individual annotation if more than one annotation of the same type is displayed. The annotation group is usually more performant, since only one underlying layer is used to draw multiple annotations.
Annotation group allows to configure group-related options, such as clustering (only for point annotations) and others.
See moreDeclaration
Swift
@_documentation(visibility: public) @_spi(Experimental) public struct CircleAnnotationGroup<Data, ID> : PrimitiveMapContent where Data : RandomAccessCollection, ID : Hashable
-
Displays a group of point annotations.
Always prefer to use annotation group over individual annotation if more than one annotation of the same type is displayed. The annotation group is usually more performant, since only one underlying layer is used to draw multiple annotations.
Annotation group allows to configure group-related options, such as clustering (only for point annotations) and others.
See moreDeclaration
Swift
@_documentation(visibility: public) @_spi(Experimental) public struct PointAnnotationGroup<Data, ID> : PrimitiveMapContent where Data : RandomAccessCollection, ID : Hashable
-
Displays a group of polygon annotations.
Always prefer to use annotation group over individual annotation if more than one annotation of the same type is displayed. The annotation group is usually more performant, since only one underlying layer is used to draw multiple annotations.
Annotation group allows to configure group-related options, such as clustering (only for point annotations) and others.
See moreDeclaration
Swift
@_documentation(visibility: public) @_spi(Experimental) public struct PolygonAnnotationGroup<Data, ID> : PrimitiveMapContent where Data : RandomAccessCollection, ID : Hashable
-
Displays a group of polyline annotations.
Always prefer to use annotation group over individual annotation if more than one annotation of the same type is displayed. The annotation group is usually more performant, since only one underlying layer is used to draw multiple annotations.
Annotation group allows to configure group-related options, such as clustering (only for point annotations) and others.
See moreDeclaration
Swift
@_documentation(visibility: public) @_spi(Experimental) public struct PolylineAnnotationGroup<Data, ID> : PrimitiveMapContent where Data : RandomAccessCollection, ID : Hashable
-
Displays view annotation.
Create a view annotation to display SwiftUI view in
Map
content.
See moreMap { ViewAnnotation(CLLocationCoordinate2D(...)) { Text("🚀") .background(Circle().fill(.red)) } }
Declaration
Swift
@_documentation(visibility: public) @_spi(Experimental) public struct ViewAnnotation : MapContent
-
A structure that creates map content from an underlying collection of identified data.
Use
ForEvery
to createMapContent
such as annotations from the identified data.
See moreprivate struct Place: Identifiable { let name: String let coordinate: CLLocationCoordinate var id: String { name } } private let places = [ Place(name: "Castle", coordinate: CLLocationCoordinate2D(...)), Place(name: "Lake", coordinate: CLLocationCoordinate2D(...)) ] var body: some View { Map { ForEvery(places) { place in ViewAnnotation(place.coordinate) { Image(named: place.name) } } } }
Declaration
Swift
@_documentation(visibility: public) @_spi(Experimental) public struct ForEvery<Data, ID> : MapContent where Data : RandomAccessCollection, ID : Hashable
-
A result builder that creates map content from closures you provide.
Declaration
Swift
@_documentation(visibility: public) @_spi(Experimental) @resultBuilder public struct MapContentBuilder
-
Displays user location via 3D Puck.
Use a 3D model to display user location
Map
content.
See moreMap { let model = Model( uri: URL(string: /* url to glb model */), orientation: [0, 0, 180] // orient source model to point the bearing property ) Puck3D(model: model, bearing: .course) }
Declaration
Swift
@_documentation(visibility: public) @_spi(Experimental) public struct Puck3D : PrimitiveMapContent
-
A SwiftUI view that displays Mapbox Map.
Use
Map
do display Mapbox Map in SwiftUI application.
See morestruct ContentView: View { static let polygon = Polygon(...) // Configures map camera to overview the given polygon. @State var viewport = Viewport.overview(geometry: Self.polygon) var body: some View { Map(viewport: $viewport) { // Displays user location. Puck2D(heading: bearing) // Displays view annotation. ViewAnnotation(CLLocationCoordinate(...)) Text("🚀") .background(Circle().fill(.red)) } // Displays polygon annotation. PolygonAnnotation(polygon: Self.polygon) .fillColor(StyleColor(.systemBlue)) .fillOpacity(0.5) .fillOutlineColor(StyleColor(.black)) .onTapGesture { print("Polygon is tapped") } } // Configures Mapbox Standard style to use "Dusk" preset. .mapStyle(.standard(lightPreset: .dusk)) } }
Declaration
Swift
@available(iOS 13.0, *) @_documentation(visibility: public) @_spi(Experimental) public struct Map : UIViewControllerRepresentable
-
A proxy for access map interfaces on underlying Mapbox Map.
See moreDeclaration
Swift
@available(iOS 13.0, *) @_documentation(visibility: public) @_spi(Experimental) public struct MapProxy
-
Provides access to the underlying
MapView
map via proxy.Wrap
Map
into a map reader to get access to the underlying map implementation.
See morevar body: some View { MapReader { proxy in Map() .onAppear { configureUnderlyingMap(proxy.map) } } }
Declaration
Swift
@available(iOS 13.0, *) @_documentation(visibility: public) @_spi(Experimental) public struct MapReader<Content> : View where Content : View