Extrusions
The Mapbox Style Specification uses the term extrusion to refer to a 3D shape displayed on a map. Extrusions are often seen on the map in the form of buildings, but any type of Polygon
shape can be extruded. The shape of a building extrusion follows the building footprint shape as if the 2D Polygon
has been stretched vertically, a specified distance in meters, from the map's surface.
Like many other visual aspects of a Mapbox map, extrusions can be styled at run time and based on the values of data fields in the source data.
Add and style an extrusions via the Maps SDK for Android's FillExtrusionLayer
. The FillExtrusionLayer
is initialized with a unique ID and a unique or shared source ID, like other Maps SDK layers. Then define the FillExtrusionLayer
layer's properties before adding the layer to the map's Style
object.
Styling
The Maps SDK for Android extrusion styling options follow the official Mapbox Style Specification.
Read the Style Specification properties to learn more about extrusion colors, opacity, pattern, coordinate offsetting, and more.
The Mapbox Android demo app's extrusions-related examples show what's possible for styling extrusions.
mapboxMap.getStyle(new Style.OnStyleLoaded() {
@Override
public void onStyleLoaded(@NonNull Style style) {
FillExtrusionLayer fillExtrusionLayer = new FillExtrusionLayer("extrusion-layer-id", "source-id");
fillExtrusionLayer.setProperties(
fillExtrusionHeight(HEIGHT_NUMBER)
);
style.addLayer(fillExtrusionLayer);
}
});
mapboxMap.getStyle {
val fillExtrusionLayer = FillExtrusionLayer("extrusion-layer-id", "source-id")
fillExtrusionLayer.setProperties(
fillExtrusionHeight(HEIGHT_NUMBER)
)
it.addLayer(fillExtrusionLayer)
}
Light
Part of the Mapbox Style Specification is the concept of light. You can adjust the color, intensity, and angle at which light hits the map, as if you were adjusting the location of the sun.
A style's light property provides a global light source for that entire style. Because these properties are applied across all layers, light
is a root property in the Style Specification rather than a paint or layout property to be defined in a single fill-extrusion layer.
Adjust the light's location and color to see how it affects the extrusion.