public class MBStyle extends Object
This class is responsible for presenting the wrapped JSON in an easy to use / navigate form for Java developers:
Access methods should return Java Objects, rather than generic maps. Additional access methods to perform common queries are expected and encouraged.
This class works closely with MBLayer
hierarchy used to represent the fill, line,
symbol, raster, circle layers. Additional support will be required to work with sprites and
glyphs.
Modifier and Type | Field and Description |
---|---|
JSONObject |
json
JSON document being wrapped by this class.
|
Constructor and Description |
---|
MBStyle(JSONObject json)
MBStyle wrapper on the provided json
|
Modifier and Type | Method and Description |
---|---|
static MBStyle |
create(Object json)
Parse MBStyle for the provided json.
|
Number |
getBearing()
(Optional) Default bearing, in degrees clockwise from true north.
|
Point2D |
getCenter()
(Optional) Default map center in longitude and latitude.
|
String |
getGlyphs()
(Optional) A URL template for loading signed-distance-field glyph sets in PBF format.
|
JSONObject |
getMetadata()
(Optional) Arbitrary properties useful to track with the stylesheet, but do not influence
rendering.
|
String |
getName()
A human-readable name for the style
|
Number |
getPitch()
(Optional) Default pitch, in degrees.
|
Map<String,MBSource> |
getSources()
Data source specifications.
|
String |
getSprite()
A base URL for retrieving the sprite image and metadata.
|
Number |
getZoom()
(Optional) Default zoom level.
|
MBLayer |
layer(String id)
Access the layer with the provided id.
|
List<MBLayer> |
layers()
Access all layers.
|
List<MBLayer> |
layers(String source)
Access layers matching provided source.
|
StyledLayerDescriptor |
transform()
Transform MBStyle to a GeoTools StyledLayerDescriptor.
|
public final JSONObject json
All methods act as accessors on this JSON document, no other state is maintained. This allows modifications to be made cleaning with out chance of side-effect.
public MBStyle(JSONObject json)
json
- Map Box Style as parsed JSONpublic static MBStyle create(Object json) throws MBFormatException
json
- Required to be a JSONObjectMBFormatException
- JSON content inconsistent with specificationpublic MBLayer layer(String id)
id
- Id of layer to accesspublic List<MBLayer> layers(String source) throws MBFormatException
source
- Data sourceMBFormatException
public String getName()
public JSONObject getMetadata()
JSONObject
containing the metadata, or an empty JSON object the style has no
metadata.public Point2D getCenter()
Point
for the map center, or null if the style contains no center.public Number getZoom()
public Number getBearing()
public Number getPitch()
public String getSprite()
public String getGlyphs()
"glyphs": "mapbox://fonts/mapbox/{fontstack}/{range}.pbf"
public StyledLayerDescriptor transform()
Copyright © 1996–2021 Geotools. All rights reserved.