Skip to main content

Set a style

Across the Mapbox ecosystem, the appearance of the map is determined by the map style. A Mapbox style is a JSON object that defines exactly how to draw a map. It defines almost everything related to a map's appearance. In the Maps SDK, you will set the style of the map after initializing the map view.

Choose a style

The style you choose for your application should reflect how your users will interact with the map and what they will use your application for. If you are not sure what style is right for you, we recommend getting started with the carefully designed, all-purpose Mapbox Standard style.

Load a style

The Maps SDK’s MapView provides an embeddable map interface. You can embed the map inside a view, allow users to manipulate it with gestures, and more. For a map to appear in the MapView, the renderer needs a style to determine how to render the map on the screen. You can rely on the default Mapbox Standard style, load a style when you first initialize the map view, or load a style at any time after the map has been initialized using one of MapboxMap’s style loading methods.

Mapbox Standard

Mapbox Standard is the default style, and instantiating a MapView without specifying any style means your map will use Mapbox Standard.

// Loads Mapbox Standard Style by default.
mapView = MapView(frame: view.bounds)

Classic style templates and custom styles

If you don’t use Mapbox Standard, you can load your style by setting styleURI property with your custom Style URI.

// Loads custom style located at CUSTOM_STYLE_URI.
mapView.mapboxMap.styleURI = StyleURI(rawValue: "CUSTOM_STYLE_URI")

Or, you can use predefined constants to load a Mapbox-designed classic style.

// Loads Mapbox-designed style.
mapView.mapboxMap.styleURI = .outdoors

Using constants will also make sure you’re using the latest version of the style:

  • Mapbox Standard: StyleURI.standard
  • Mapbox Streets: StyleURI.streets
  • Mapbox Outdoors: StyleURI.outdoors
  • Mapbox Satellite: StyleURI.satellite
  • Mapbox Satellite Streets: StyleURI.satelliteStreets
  • Mapbox Light: StyleURI.light
  • Mapbox Dark: StyleURI.dark
Use loadStyleJSON

Though less common, you can also use MapboxMap’s loadStyleJSON to load a style if you've written style JSON manually.

Switch styles at runtime

You can change the map style any time after initializing the map using any of the style loading methods described above. If you added any layers at runtime, you will need to re-add layers after the new style is loaded or use addPersistentLayer when adding any layers to the initial style to make the layers persistent across style changes.

Configure a style

Depending on what map style you choose, you have different configuration options available to customize aspects of your style such as fonts, colors, and more.

Mapbox Standard

The underlying design paradigm to Mapbox Standard is different from what you know from the classic styles templates. We’re establishing the concept of a basemap; Mapbox Standard being the first to follow this paradigm. You can consider everything that is maintained by Mapbox (natural features, roads, buildings etc.) as the basemap into which you embed your custom layers. The differentiation is important because different rules apply to the basemap and custom layers.

To change the visual appearance of the Standard basemap, you need to use the setStyleImportConfigProperty method. Mapbox Standard offers 6 configuration properties that can be used to change the appearance of the basemap using setStyleImportConfigProperty:

showPlaceLabelsBoolShows and hides place label layers.
showRoadLabelsBoolShows and hides all road labels, including road shields.
showPointOfInterestLabelsBoolShows or hides all POI icons and text.
showTransitLabelsBoolShows or hides all transit icons and text.
lightPresetStringSwitches between 4 time-of-day states: dusk, dawn, day, and night.
Lights can also be fully customized beyond the presets using the Mapbox style specification.
fontArrayDefines font family for the style from predefined options. Options: Alegreya, Alegreya SC, Asap, Barlow, DIN Pro, EB Garamond, Faustina, Frank Ruhl Libre, Heebo, Inter, League Mono, Montserrat, Poppins, Raleway, Roboto, Roboto Mono, Rubik, Source, Code Pro, Spectral, Ubuntu, Noto Sans CJK JP, Open Sans, Manrope, Source Sans Pro, Lato

Here’s an example illustrating how to switch the 3D lights from the default preset, day, to another preset, dusk.

mapView.mapboxMap.setStyleImportConfigProperty(for: "basemap", config: "lightPreset", value: "dusk")

Similarly, you can set other configuration properties on the Standard style such as showing POIs, place labels, or specific fonts:

mapView.mapboxMap.setStyleImportConfigProperty(for: "basemap", config: "showPointOfInterestLabels", value: false)

Other options to customize your map using Mapbox Standard are by configuring root properties, or styling your custom data such that it reflects your personal preferences. Note that all the configurations are also available in the Mapbox Studio.

For custom layers that you add to the Mapbox Standard basemap, all configuration options are defined in the Mapbox Style Specification.

Experimental MapStyle API

Explore the new experimental MapStyle API which simplifies configuration of the Standard Style.


Style imports

To work with styles like Mapbox Standard, we've introduced Style APIs that allow you to import other styles into the main style you display to your users. These styles will be imported by reference, so updates to them will be reflected in your main style without additional work needed on your side. For example, imagine you have style A and style B. The Style API will allow you to import A into B. Upon importing, you can set configurations that apply to A and adjust them at runtime. The configuration properties for the imported style A will depend on what the creator of style A chooses to be configurable. For the Standard style, 6 configuration properties are available for setting lighting, fonts, and label display options. To import a style, you need to add an imports property to your Style JSON. In the above example, you would add "imports" to your Style JSON for B to import style A and set various configurations as defined in style A in the schema root property.

"imports": [
"id": "A",
"url": "STYLE_URL_FOR_A",
"config": {
"font": "Montserrat",
"lightPreset": "dusk",
"showPointOfInterestLabels": true,
"showTransitLabels": false,
"showPlaceLabels": true,
"showRoadLabels": false

For a full example of importing a style, see our Standard Style Example. This example imports the Standard style into another style Real Estate New York. It then modifies the configurations for the imported Standard style at runtime using the following APIs we've introduced on the StyleManager object:

  • StyleManager/styleImports, which returns all the styles you have imported into your main style
  • StyleManager/removeStyleImport(for:), which removes the style import with the passed Id
  • StyleManager/getStyleImportSchema(for:), which returns the full schema describing the style import with the passed Id
  • StyleManager/getStyleImportConfigProperties(for:), which returns all the configuration properties of the style import with the passed Id
  • StyleManager/getStyleImportConfigProperty(for:config:), which returns the specified configuration property of the style import with the passed Id
  • StyleManager/setStyleImportConfigProperties(for:configs:), which sets all the configuration properties of the style import with the passed Id
  • StyleManager/setStyleImportConfigProperty(for:config:value:), which sets the specified configuration property of the style import with the passed Id

Classic style templates and custom styles

The configuration options for classic style templates and custom styles are defined in the Mapbox Style Specification. Note that all the configurations are also available in the Mapbox Studio.

Was this page helpful?