Other Structures

The following structures are available globally.

  • Options for playback when using MapRecorder

    See more

    Declaration

    Swift

    public struct MapPlayerOptions
  • Options for recording the map when using MapRecorder

    See more

    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 to Combine.Publisher. It’s behavior is aligned with Publisher for easier future migration to Combine. If your app supports iOS >= 13.0, use Signal as Combine.Publisher .
    See more

    Declaration

    Swift

    public struct Signal<Payload>
    extension Signal: Combine.Publisher
  • Various options needed for tile cover.

    See more

    Declaration

    Swift

    @_documentation(visibility: public)
    @_spi(Experimental)
    public struct TileCoverOptions
  • Enable os_signpost generation in some components

    By 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:

    1. The empty value will enable all components tracing. Equals to enabled.
    2. The value of 0 or disabled will set a default value to disabled.
    3. 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").
    4. Value is case-insensitive.
    See more

    Declaration

    Swift

    public struct Tracing : OptionSet
  • Options for enabling debugging features in a map.

    See more

    Declaration

    Swift

    public struct MapViewDebugOptions : OptionSet, Hashable
  • A structure that defines additional information about map content gesture

    See more

    Declaration

    Swift

    public struct MapContentGestureContext
  • The azimuth (orientation) of the user’s device, relative to true or magnetic north.

    See more

    Declaration

    Swift

    public struct Heading : Equatable
  • Represents the interpolated data ready to render the user location puck.

    See more

    Declaration

    Swift

    public struct PuckRenderingData : Equatable
  • A shim that makes it possible to subscribe to MapboxMap and Snapshotter events via the old onNext and onEvery methods. It is here to simplify migration from v10 to v11, but will be removed in v12.

    See more

    Declaration

    Swift

    @available(*, deprecated)
    public struct MapEventType<Payload>
  • Layer with custom rendering implementation

    With a power of CustomLayerHost you can implement your own Metal rendering behaviour and manipulate layer as a usual one.

    See more

    Declaration

    Swift

    public struct CustomLayer : Layer
  • A style’s fog property is a global effect that improves depth perception by fading out distant objects.

    See more

    Declaration

    Swift

    public struct Atmosphere : Codable
  • Defines scaling mode. Only applies to location-indicator type layers.

    See more

    Declaration

    Swift

    public struct ModelScaleMode : RawRepresentable, Codable, Hashable
  • The name of the projection to be used for rendering the map.

    See more

    Declaration

    Swift

    public struct StyleProjectionName : RawRepresentable, Codable, Hashable
  • Map style configuration.

    Use MapStyle with mapStyle or Map (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 mapStyle will lead to the style reloading. You can observe result of the style reloading in onStyleLoaded or onStyleLoaded events.

    See more

    Declaration

    Swift

    @_documentation(visibility: public)
    @_spi(Experimental)
    public struct MapStyle : Equatable
  • Defines the available light presets in the Mapbox Standard Style.

    See more

    Declaration

    Swift

    @_documentation(visibility: public)
    @_spi(Experimental)
    public struct StandardLightPreset : RawRepresentable, Hashable
  • Specifies configuration parameters for style imports.

    See more

    Declaration

    Swift

    @_documentation(visibility: public)
    @_spi(Experimental)
    public struct StyleImportConfiguration : Equatable
  • Describes the projection used to render the map.

    See more

    Declaration

    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 more

    Declaration

    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 more

    Declaration

    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 more

    Declaration

    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 more

    Declaration

    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.

    Map {
        ViewAnnotation(CLLocationCoordinate2D(...)) {
           Text("🚀")
              .background(Circle().fill(.red))
        }
    }
    
    See more

    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 create MapContent such as annotations from the identified data.

    private 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)
            }
          }
        }
    }
    

    Note

    ForEvery is similar to SwiftUI ForEach, but works with MapContent.
    See more

    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 2D Puck.

    Create the 2D Puck in Map content.

    Map {
        Puck2D(bearing: .heading)
            .showsAccuracyRing(true)
    }
    
    See more

    Declaration

    Swift

    @_documentation(visibility: public)
    @_spi(Experimental)
    public struct Puck2D : PrimitiveMapContent
  • Displays user location via 3D Puck.

    Use a 3D model to display user location Map content.

    Map {
        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)
    }
    
    See more

    Declaration

    Swift

    @_documentation(visibility: public)
    @_spi(Experimental)
    public struct Puck3D : PrimitiveMapContent
  • Map

    A SwiftUI view that displays Mapbox Map.

    Use Map do display Mapbox Map in SwiftUI application.

    struct 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))
        }
    }
    
    See more

    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 more

    Declaration

    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.

    var body: some View {
        MapReader { proxy in
            Map()
                .onAppear {
                    configureUnderlyingMap(proxy.map)
                }
        }
    }
    
    See more

    Declaration

    Swift

    @available(iOS 13.0, *)
    @_documentation(visibility: public)
    @_spi(Experimental)
    public struct MapReader<Content> : View where Content : View
  • Specifies the animation for the map Viewport.

    See more

    Declaration

    Swift

    @_documentation(visibility: public)
    @_spi(Experimental)
    public struct ViewportAnimation