public class Style
extends java.lang.Object
To create new instances of this object, create a new instance using a Style.Builder
and load the style with
MapboxMap#setStyle(Builder)
. This object is returned from MapboxMap.getStyle()
once the style
has been loaded by underlying map.
Modifier and Type | Class and Description |
---|---|
static class |
Style.Builder
Builder for composing a style object.
|
static interface |
Style.OnStyleLoaded
Callback to be invoked when a style has finished loading.
|
static interface |
Style.StyleUrl
Indicates the parameter accepts one of the values from Style.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DARK
Dark: Subtle dark backdrop for data visualizations.
|
static java.lang.String |
LIGHT
Light: Subtle light backdrop for data visualizations.
|
static java.lang.String |
MAPBOX_STREETS
Mapbox Streets: A complete basemap, perfect for incorporating your own data.
|
static java.lang.String |
OUTDOORS
Outdoors: A general-purpose style tailored to outdoor activities.
|
static java.lang.String |
SATELLITE
Satellite: A beautiful global satellite and aerial imagery layer.
|
static java.lang.String |
SATELLITE_STREETS
Satellite Streets: Global satellite and aerial imagery with unobtrusive labels.
|
static java.lang.String |
TRAFFIC_DAY
Traffic Day: Color-coded roads based on live traffic congestion data.
|
static java.lang.String |
TRAFFIC_NIGHT
Traffic Night: Color-coded roads based on live traffic congestion data, designed to maximize
legibility in low-light situations.
|
Modifier and Type | Method and Description |
---|---|
void |
addImage(java.lang.String name,
Bitmap image)
Adds an image to be used in the map's style
|
void |
addImage(java.lang.String name,
Bitmap bitmap,
boolean sdf)
Adds an image to be used in the map's style
|
void |
addImages(java.util.HashMap<java.lang.String,Bitmap> images)
Adds an images to be used in the map's style.
|
void |
addImages(java.util.HashMap<java.lang.String,Bitmap> images,
boolean sdf)
Adds an images to be used in the map's style.
|
void |
addLayer(Layer layer)
Adds the layer to the map.
|
void |
addLayerAbove(Layer layer,
java.lang.String above)
Adds the layer to the map.
|
void |
addLayerAt(Layer layer,
int index)
Adds the layer to the map at the specified index.
|
void |
addLayerBelow(Layer layer,
java.lang.String below)
Adds the layer to the map.
|
void |
addSource(Source source)
Adds the source to the map.
|
Bitmap |
getImage(java.lang.String id)
Get an image from the map's style using an id.
|
java.lang.String |
getJson()
Returns the current style json.
|
Layer |
getLayer(java.lang.String id)
Get the layer by id
|
<T extends Layer> |
getLayerAs(java.lang.String layerId)
Tries to cast the Layer to T, throws ClassCastException if it's another type.
|
java.util.List<Layer> |
getLayers()
Retrieve all the layers in the style
|
Light |
getLight()
Get the light source used to change lighting conditions on extruded fill layers.
|
Source |
getSource(java.lang.String id)
Retrieve a source by id
|
<T extends Source> |
getSourceAs(java.lang.String sourceId)
Tries to cast the Source to T, throws ClassCastException if it's another type.
|
java.util.List<Source> |
getSources()
Retrieve all the sources in the style
|
TransitionOptions |
getTransition()
Get the transition for style changes.
|
java.lang.String |
getUrl()
Returns the current style url.
|
boolean |
isFullyLoaded()
Returns true if the style is fully loaded.
|
void |
removeImage(java.lang.String name)
Removes an image from the map's style.
|
boolean |
removeLayer(Layer layer)
Removes the layer.
|
boolean |
removeLayer(java.lang.String layerId)
Removes the layer.
|
boolean |
removeLayerAt(int index)
Removes the layer.
|
boolean |
removeSource(Source source)
Removes the source, preserving the reference for re-use
|
boolean |
removeSource(java.lang.String sourceId)
Removes the source from the style.
|
void |
setTransition(TransitionOptions transitionOptions)
Set the transition duration for style changes.
|
public static final java.lang.String MAPBOX_STREETS
public static final java.lang.String OUTDOORS
public static final java.lang.String LIGHT
public static final java.lang.String DARK
public static final java.lang.String SATELLITE
public static final java.lang.String SATELLITE_STREETS
public static final java.lang.String TRAFFIC_DAY
public static final java.lang.String TRAFFIC_NIGHT
public java.lang.String getUrl()
public java.lang.String getJson()
public java.util.List<Source> getSources()
public void addSource(Source source)
source
- the source to addpublic Source getSource(java.lang.String id)
id
- the source's idpublic <T extends Source> T getSourceAs(java.lang.String sourceId)
T
- the generic type of a SourcesourceId
- the id used to look up a layerpublic boolean removeSource(java.lang.String sourceId)
sourceId
- the source to removepublic boolean removeSource(Source source)
source
- the source to removepublic void addLayer(Layer layer)
layer
- the layer to addpublic void addLayerBelow(Layer layer, java.lang.String below)
layer
- the layer to addbelow
- the layer id to add this layer beforepublic void addLayerAbove(Layer layer, java.lang.String above)
layer
- the layer to addabove
- the layer id to add this layer abovepublic void addLayerAt(Layer layer, int index)
layer
- the layer to addindex
- the index to insert the layer atpublic Layer getLayer(java.lang.String id)
id
- the layer's idpublic <T extends Layer> T getLayerAs(java.lang.String layerId)
T
- the generic attribute of a LayerlayerId
- the layer id used to look up a layerpublic java.util.List<Layer> getLayers()
public boolean removeLayer(java.lang.String layerId)
layerId
- the layer to removepublic boolean removeLayer(Layer layer)
layer
- the layer to removepublic boolean removeLayerAt(int index)
index
- the layer indexpublic void addImage(java.lang.String name, Bitmap image)
name
- the name of the imageimage
- the pre-multiplied Bitmappublic void addImage(java.lang.String name, Bitmap bitmap, boolean sdf)
name
- the name of the imagebitmap
- the pre-multiplied Bitmapsdf
- the flag indicating image is an SDF or template imagepublic void addImages(java.util.HashMap<java.lang.String,Bitmap> images)
public void addImages(java.util.HashMap<java.lang.String,Bitmap> images, boolean sdf)
public void removeImage(java.lang.String name)
name
- the name of the image to removepublic Bitmap getImage(java.lang.String id)
id
- the id of the imagepublic void setTransition(TransitionOptions transitionOptions)
Set the transition duration for style changes.
The default value for delay and duration is zero, so any changes take effect without animation.transitionOptions
- the transition optionspublic TransitionOptions getTransition()
Get the transition for style changes.
The default value for delay and transition is zero, so any changes take effect without animation.public Light getLight()
public boolean isFullyLoaded()
© 2015–2019 Mapbox. All rights reserved.