Overview
TheStyle component automatically converts Mapbox GL Style Spec JSON into React Native components. It supports sources and layers from the style specification.
Props
A JSON object conforming to the Mapbox Style Specification, or a URL to such JSON.Only
sources and layers fields are supported. Other fields like sprites and glyphs will be ignored.Style Objects
Styles are written as JavaScript objects with camelCase property names (e.g.,fillColor instead of fill-color).
Basic Style Example
Style Expressions
Mapbox expressions allow for dynamic, data-driven styling. See the Mapbox expression specification for complete details.Zoom-Based Expressions
Create styles that change based on the map’s zoom level.Attribute-Based Expressions
Create styles that change based on feature properties.Nested Expressions
Combine zoom and attribute expressions for composite styling.Complete Examples
Clustered Points
3D Buildings
Supported Properties
TheStyle component supports most layer and source types from the Mapbox Style Specification:
Layer Types
fill- FillLayerline- LineLayersymbol- SymbolLayercircle- CircleLayerheatmap- HeatmapLayerfill-extrusion- FillExtrusionLayerraster- RasterLayerbackground- BackgroundLayer
Source Types
vector- VectorSourceraster- RasterSourcegeojson- ShapeSourceimage- ImageSource
Notes
- Property names are automatically converted from kebab-case (style spec) to camelCase (React Native)
- Not all style spec attributes are supported - check the documentation for specific layer types
- The
Stylecomponent can fetch remote style JSON by passing a URL