MapStyle
@_documentation(visibility: public)
@_spi(Experimental)
public struct MapStyle : Equatable
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.
-
Creates a map style using a Mapbox Style JSON.
Please consult Mapbox Style Specification describing the JSON format.
Important
For the better performance with large local Style JSON please consider loading style from the file system via the
init(uri:importConfigurations:)initializer.Declaration
Swift
@_documentation(visibility: public) public init(json: String, importConfigurations: [StyleImportConfiguration] = [])Parameters
jsonA Mapbox Style JSON string.
importConfigurationsStyle import configurations to be applied on style load.
-
Creates a map style using StyleURI.
Use this initializer to make use of pre-defined Mapbox Styles, or load a custom style bundled with the application, or over the network.
Declaration
Swift
@_documentation(visibility: public) public init(uri: StyleURI, importConfigurations: [StyleImportConfiguration] = [])Parameters
uriA URI pointing to a Mapbox style URI (mapbox://styles/{user}/{style}), a full HTTPS URI, or a path to a local file.
importConfigurationsStyle import configurations to be applied on style load.
-
Mapbox Standard is a general-purpose style with 3D visualization.
Declaration
Swift
@_documentation(visibility: public) public static var standard: MapStyle { get } -
standard(lightPreset:font:showPointOfInterestLabels:showTransitLabels:showPlaceLabels:showRoadLabels:)Mapbox Standard is a general-purpose style with 3D visualization.
Declaration
Swift
@_documentation(visibility: public) public static func standard( lightPreset: StandardLightPreset?, font: String? = nil, showPointOfInterestLabels: Bool? = nil, showTransitLabels: Bool? = nil, showPlaceLabels: Bool? = nil, showRoadLabels: Bool? = nil ) -> MapStyle -
Mapbox Streets is a general-purpose style with detailed road and transit networks.
Declaration
Swift
@_documentation(visibility: public) public static var streets: MapStyle { get } -
Mapbox Outdoors is a general-purpose style tailored to outdoor activities.
Declaration
Swift
@_documentation(visibility: public) public static var outdoors: MapStyle { get } -
Mapbox Light is a subtle, light-colored backdrop for data visualizations.
Declaration
Swift
@_documentation(visibility: public) public static var light: MapStyle { get } -
Mapbox Dark is a subtle, dark-colored backdrop for data visualizations.
Declaration
Swift
@_documentation(visibility: public) public static var dark: MapStyle { get } -
The Mapbox Satellite style is a base-map of high-resolution satellite and aerial imagery.
Declaration
Swift
@_documentation(visibility: public) public static var satellite: MapStyle { get } -
The Mapbox Satellite Streets style combines the high-resolution satellite and aerial imagery of Mapbox Satellite with unobtrusive labels and translucent roads from Mapbox Streets.
Declaration
Swift
@_documentation(visibility: public) public static var satelliteStreets: MapStyle { get }
MapStyle Structure Reference