Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
Style.Builder |
fromJson(String styleJson)
Will load a new map style from a json string.
|
Style.Builder |
fromUrl(String url)
Will loads a new map style asynchronous from the specified URL.
|
Style.Builder |
withBitmapImages(<any>... values)
Will add the images when the map style has loaded.
|
Style.Builder |
withBitmapImages(boolean sdf,
<any>... values)
Will add the images when the map style has loaded.
|
Style.Builder |
withDrawableImages(<any>... values)
Will add the drawables as images when the map style has loaded.
|
Style.Builder |
withDrawableImages(boolean sdf,
<any>... values)
Will add the drawables as images when the map style has loaded.
|
Style.Builder |
withImage(String id,
Bitmap image)
Will add the image when the map style has loaded.
|
Style.Builder |
withImage(String id,
Bitmap image,
boolean sdf)
Will add the image when the map style has loaded.
|
Style.Builder |
withImage(String id,
Drawable drawable)
Will add the drawable as image when the map style has loaded.
|
Style.Builder |
withImage(String id,
Drawable drawable,
boolean sdf)
Will add the drawable as image when the map style has loaded.
|
Style.Builder |
withLayer(Layer layer)
Will add the layer when the style has loaded.
|
Style.Builder |
withLayerAbove(Layer layer,
String aboveLayerId)
Will add the layer when the style has loaded above a specified layer id.
|
Style.Builder |
withLayerAt(Layer layer,
int index)
Will add the layer when the style has loaded at a specified index.
|
Style.Builder |
withLayerBelow(Layer layer,
String belowLayerId)
Will add the layer when the style has loaded below a specified layer id.
|
Style.Builder |
withLayers(Layer... layers)
Will add the layers when the style has loaded.
|
Style.Builder |
withSource(Source source)
Will add the source when map style has loaded.
|
Style.Builder |
withSources(Source... sources)
Will add the sources when map style has loaded.
|
Style.Builder |
withTransition(TransitionOptions transition)
Will add the transition when the map style has loaded.
|
public Style.Builder fromUrl(String url)
Will loads a new map style asynchronous from the specified URL.
url
can take the following forms:
Style#StyleUrl
: load one of the bundled styles in Style
.mapbox://styles/<user>/<style>
:
loads the style from a Mapbox account.
user
is your username. style
is the ID of your custom
style created in Mapbox Studio.http://...
or https://...
:
loads the style over the Internet from any web server.asset://...
:
loads the style from the APK assets/
directory.
This is used to load a style bundled with your app.file://...
:
loads the style from a file path. This is used to load a style from disk.
null
: loads the default Style.MAPBOX_STREETS
style.
This method is asynchronous and will return before the style finishes loading.
If you wish to wait for the map to finish loading, listen to the MapView.OnDidFinishLoadingStyleListener
callback or use MapboxMap#setStyle(String, OnStyleLoaded)
instead.
MapView.OnDidFailLoadingMapListener
callback
will be triggered.url
- The URL of the map styleStyle
public Style.Builder fromJson(String styleJson)
If the style fails to load or an invalid style URL is set, the map view will become blank.
An error message will be logged in the Android logcat and MapView.OnDidFailLoadingMapListener
callback
will be triggered.
public Style.Builder withSource(Source source)
source
- the source to addpublic Style.Builder withSources(Source... sources)
sources
- the sources to addpublic Style.Builder withLayer(Layer layer)
layer
- the layer to be addedpublic Style.Builder withLayers(Layer... layers)
layers
- the layers to be addedpublic Style.Builder withLayerAt(Layer layer, int index)
layer
- the layer to be addedpublic Style.Builder withLayerAbove(Layer layer, String aboveLayerId)
layer
- the layer to be addedpublic Style.Builder withLayerBelow(Layer layer, String belowLayerId)
layer
- the layer to be addedpublic Style.Builder withTransition(TransitionOptions transition)
transition
- the transition to be addedpublic Style.Builder withImage(String id, Drawable drawable)
id
- the id for the imagedrawable
- the drawable to be converted and addedpublic Style.Builder withDrawableImages(<any>... values)
values
- pairs, where first is the id for te image and second is the drawablepublic Style.Builder withImage(String id, Bitmap image)
id
- the id for the imageimage
- the image to be addedpublic Style.Builder withBitmapImages(<any>... values)
values
- pairs, where first is the id for te image and second is the bitmappublic Style.Builder withImage(String id, Drawable drawable, boolean sdf)
id
- the id for the imagedrawable
- the drawable to be converted and addedsdf
- the flag indicating image is an SDF or template imagepublic Style.Builder withDrawableImages(boolean sdf, <any>... values)
sdf
- the flag indicating image is an SDF or template imagevalues
- pairs, where first is the id for te image and second is the drawablepublic Style.Builder withImage(String id, Bitmap image, boolean sdf)
id
- the id for the imageimage
- the image to be addedsdf
- the flag indicating image is an SDF or template imagepublic Style.Builder withBitmapImages(boolean sdf, <any>... values)
sdf
- the flag indicating image is an SDF or template imagevalues
- pairs, where first is the id for te image and second is the bitmap© 2015–2019 Mapbox. All rights reserved.