3D buildings in a Mapbox Style
You can include 3d buildings into your Mapbox Styles. If you are using Mapbox Standard or Mapbox Satellite Standard, 3d buildings will be included in your map by default, otherwise you will need to add the component manually to your style.
If you build a new style using the Start from Scratch method in Mapbox Studio, you will need to follow a set of steps to include 3d buildings in your map.
Components vs. layers
You can add 3d buildings to a style created with the Start from Scratch method, in one of two ways:
Option 1: Style with components
This option allows you to quickly add 3D buildings to your style using built in components in the Mapbox Studio editor. This is recommended for implementation with less customization requirements and that use the newest Mapbox Studio frameworks.
Option 2: Style an individual layer
This option allows you to import building data as a source and create a layer based on that data. If you need more complex customization options or you have a current style that uses older versions of Mapbox Studio, use this option.
Regardless of which approach you take, the following sections will be the same for each method:
Creating your style
Create a new style from scratch or if you have an existing style you can skip to Option 1 or Option 2.
Step 1: Create a blank style
To begin, you will create a new map style in Mapbox Studio:
- Log in to your Mapbox account and navigate to your Styles page.
- Create a new style.
- In the new window, click the New style button
- Then, select Start from scratch.
- Rename the map.
- In the Mapbox Studio style editor, click the title field in the upper left side of your screen.
- Next, change the title of your style to "3D buildings".
Step 2: Customize the basemap
- Render the globe.
- Click the + button and selection
Components > Land & Water. - This will add the Land & Water layer which will render the globe in your style.
- Click the + button and selection
- In the Land & Water panel, click on the color swatch next to Base and set the color to
#af5ea5ff. - Next, enable the atmosphere in your style:
- Select the Global tab.
- Click Atmosphere.
- Toggle on Enable Atmosphere.
- Move your viewport to an area with many buildings.
- In the search bar in the upper right corner of your screen, search for
20 W 34th St. New Yorkand select the first result. - This will set the viewport over the Empire State Building.
- In the search bar in the upper right corner of your screen, search for
The map view will move so that it is centered on the Empire State building in New York City, and will look like the image below:
If you would like to learn more about creating a basemap style from scratch and adding more in depth styles, see our Create a custom basemap style with Mapbox Studio guide.
Now that you have your map set up, you can turn on 3D buildings in one of two ways:
- Option 1: Style with components
- Components allow you to quickly add 3D buildings to your style, using built in functionality in the Mapbox Studio editor.
- Option 2: Style an individual layer
- Layers are useful for integrations where you need to import data from different sources.
Option 1: Add buildings with Components
Components allow you to quickly add 3D buildings to your custom style, like how you added the Land & Water component in Step 1.
Now that you have your basemap set up, you Turn on 3D buildings in the Buildings component:
- Click on the Layers panel.
- Click the + button and select Components > Buildings.
- In the new properties panel, click the Building styles dropdown and select 3D.
- Hold down the
CTRLbutton and drag your mouse to adjust the pitch of the viewport.- You will see 3D buildings appear on your map, but the default map view looks straight "down", which does not show off the 3D buildings.
- Lastly, adjust the opacity of the building.
- In the building properties panel, drag the Fill opacity slider to the right or enter a higher number to increase the opacity of the layer.
Next, you will Style the map to change the camera pitch and adjust the style's lighting.
Option 2: Add buildings using an individual layer
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.
Step 1: Create a new buildings layer
If your style doesn't contain a building layer, you can create one:
- Click the Layers panel on the left side of your screen.
- Click the plus button (+) button at the top of the panel.
- Select Custom Layer.
- In the property panel, click the field below Source to select a data source.
- Find the Mapbox Streets v8
buildingsource 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.
- Click the Type property in the New layer panel and select the
Fill extrusionoption.- If prompted, click Okay to confirm that you want to change the layer's type.
- Click the Style tab to view the layer's style panel, which you will make adjustments to in the next step.
- Move your viewport to an area with many buildings.
- In the search bar in the upper right corner of your screen, search for
20 W 34th St. New Yorkand select the first result. - This will set the viewport over the Empire State Building.
- In the search bar in the upper right corner of your screen, search for
You will see flat black shapes where the 3D buildings will appear and in the next step you will style them to adjust their height and color.
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.
Step 2: Set the height and base height properties
Now that you have imported the necessary building data, you can adjust their height on the map.
- Select your building layer and open the Extrusion tab.
- Click on the Height property.
- Select Style across data range towards the middle of the panel.
- In the new panel that appear select height.
- Leave the first stop with the default values:
0in the input field.- meters as 0.
- Adjust the values of the second stop:
- Click in the input field and set the value to
999. - Click on 0 meters and in the pop-up that appears, set meters to
999.
- Click in the input field and set the value to
- Next, select the Base Height property.
- Select Style across data range towards the middle of the panel.
- In the new panel that appears select min_height.
- Leave the first stop with the default values:
0in the input field.- meters as 0.
- Adjust the values of the second stop:
- Click in the input field and set the value to
999. - Click on 0 meters and in the pop-up that appears, set meters to
999.
- Click in the input field and set the value to
Now you will see black buildings expand, showcasing different heights for each of the individual buildings. Next, you will adjust the colors of the buildings.
Step 3: Change the building color
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:
- Click on the Color field and change it to
#eea7e4ff. - Click on the Opacity field and change it to
0.6.
Next, you will style the map to change the camera pitch and adjust the style's lighting.
Style the map
Step 1: Change the camera pitch
It may be 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:
- Right click on the map view and drag the mouse.
- Move the map until you reach the desired pitch.
To experiment with different camera pitches and appropriate zoom levels for the view you want, use our handy Location Helper tool.
Step 2: Adjust the style's lighting
Changing the lighting intensity for a fill extrusion layer highlights architectural details and makes it easier to distinguish between different buildings.
- Open the Globe panel and select 3D Lighting.
- Click on Enable Ambient and toggle it on.
- Next, click Enable Directional and toggle it on.
- Note: You will not be able to see Directional Lighting if you do not turn on Ambient Lighting.
- Next, click Intensity and adjust the slider to change the directional light intensity to
0.75. - Lastly, select Cast Shadows and set it to true.
You should now see a map with directly and ambient lighting with shadows protruding from the buildings.
In the final step, you will walk through publishing your style so you can access it from webpages or mobile applications.
Publish the style
When you have finished editing your new map style, you will publish your changes.
- Click the Publish button in the upper right side of the screen.
- Review your changes.
- When you click the publish button, a window will display the difference between the previous version and the current version.
- If you're happy with the edits you made, click Publish.
- Your style will now be available to share from a variety of tools and applications.
- Click the Share button in the top toolbar to see all options.
Learn more
You might also be interested in:
- Reviewing the Mapbox Studio Manual to learn more about Mapbox Studio.
- Exploring other tutorials related to Mapbox Studio.
- Learning how to customize your map in more depth with our Create a custom basemap style with Mapbox Studio tutorial.
- Learning how to add precipitation to the map with our snow and rain examples.