This tutorial will walk you through the process of adding a 3D building layer to a map style using Mapbox Studio.
Before you start this tutorial, you need to create a Mapbox account.
There are two options for styling 3D buildings:
Regardless of how the approach you take, the last two steps, Adjust the style's lighting and Publish the style, will be the same.
If you are using one our templates built using style components, you can add 3D buildings with component properties in the Components tab.
To begin, you will create a new map style in Mapbox Studio:
The map view will move so that it is centered on the Empire State building in New York City.
Turn on 3D buildings in the Buildings component:
You will see 3D buildings appear on your map. The default map view looks straight "down", which does not show off the 3D buildings. You can change the pitch now by right clicking on the map view and dragging your mouse, or you can wait until the Add the finishing touches step.
The 3D buildings appear slightly transparent by default. In this step, you will adjust the opacity of the buildings to make them more opaque.
Clear value
option or click each stop to access the Fill opacity slider.Next, you will add the finishing touches to change the camera pitch and adjust the style's lighting.
If you are using an older style, a custom style that was not built using style components, or custom building data, the process for adding 3D buildings will have a few more steps. You will need to update or create a new building
layer and change several layer properties in the Layers tab.
To begin, open your existing style in Mapbox Studio.
Your style will open in the Mapbox Studio style editor.
If your style doesn't contain a building
layer, you can create one:
building
source and select it.This will create your new layer and open it in x-ray view, where you can inspect the data from its source.
Fill extrusion
option. If prompted, click Okay to confirm that you want to change the layer's type. 8. If any filters are applied to this layer, remove them. 9. Click the Style tab to toggle to layer's style panel.Now that the building layer's type has been changed, its style settings need to be adjusted to show the desired 3D effect.
This tutorial uses the building
layer in Mapbox Streets v8.
If you have custom building data that you would like to use instead, you can upload
your data to Mapbox as a tileset using Mapbox Studio,
Mapbox Tiling Service,
or the Mapbox Uploads API.
Next, you will adjust the layer's height and base height properties to achieve a 3D effect.
<Icon name='extrusion' inline={true} /> building
layer and click on the Height property.0
and a Fill height of 0
.999
and the Fill height to 999
.You can also set the base height property of your layer to handle cases where a building has a base as well as a separate taller part with a different architectural shape. Setting the base height property ensures that your buildings will have a more nuanced architectural appearance.
<Icon name='extrusion' inline={true} /> building
layer and click on Base height.0
and a Fill base height of 0
. Leave these settings as they are.999
and change the Fill base height option to 999
.The default black color of the buildings makes it hard to distinguish details, so this style will use a lighter color and a lower opacity:
#d0b47c
.0.6
.Next, you will add the finishing touches to change the camera pitch and adjust the style's lighting.
It's difficult to see the impact of changing these settings because the default map view looks straight "down". To adjust the pitch and make the 3D buildings easier to see:
To experiment with different camera pitches and appropriate zoom levels for the view you want, use our handy Location Helper tool.
Changing the lighting intensity for a fill extrusion layer highlights architectural details and makes it easier to distinguish between different buildings.
0.75
.When you have finished editing your new map style, you will publish your changes.
Congratulations on adding 3D buildings to your map style!
You can use your Mapbox style to add a map on your website or in a web or mobile application. Take a look at the Publish style section of the Mapbox Studio Manual to learn more.
You might also be interested in: