public static class Style.Builder
extends java.lang.Object
Modifier and Type | Class | Description |
---|---|---|
static class |
Style.Builder.ImageWrapper |
|
class |
Style.Builder.LayerAboveWrapper |
|
class |
Style.Builder.LayerAtWrapper |
|
class |
Style.Builder.LayerBelowWrapper |
|
class |
Style.Builder.LayerWrapper |
Constructor | Description |
---|---|
Builder() |
Modifier and Type | Method | Description |
---|---|---|
Style.Builder |
fromJson(java.lang.String styleJson) |
Will load a new map style from a json string.
|
Style.Builder |
fromUri(java.lang.String uri) |
Will loads a new map style asynchronous from the specified URI.
|
Style.Builder |
fromUrl(java.lang.String url) |
Deprecated.
use
fromUri(String) instead |
java.util.List<Style.Builder.ImageWrapper> |
getImages() |
|
java.lang.String |
getJson() |
|
java.util.List<Style.Builder.LayerWrapper> |
getLayers() |
|
java.util.List<Source> |
getSources() |
|
java.lang.String |
getUri() |
|
Style.Builder |
withBitmapImages(boolean sdf,
android.util.Pair<java.lang.String,android.graphics.Bitmap>... values) |
Will add the images when the map style has loaded.
|
Style.Builder |
withBitmapImages(android.util.Pair<java.lang.String,android.graphics.Bitmap>... values) |
Will add the images when the map style has loaded.
|
Style.Builder |
withDrawableImages(boolean sdf,
android.util.Pair<java.lang.String,android.graphics.drawable.Drawable>... values) |
Will add the drawables as images when the map style has loaded.
|
Style.Builder |
withDrawableImages(android.util.Pair<java.lang.String,android.graphics.drawable.Drawable>... values) |
Will add the drawables as images when the map style has loaded.
|
Style.Builder |
withImage(java.lang.String id,
android.graphics.Bitmap image) |
Will add the image when the map style has loaded.
|
Style.Builder |
withImage(java.lang.String id,
android.graphics.Bitmap image,
boolean sdf) |
Will add the image when the map style has loaded.
|
Style.Builder |
withImage(java.lang.String id,
android.graphics.Bitmap image,
boolean sdf,
java.util.List<ImageStretches> stretchX,
java.util.List<ImageStretches> stretchY,
ImageContent content) |
Will add the image when the map style has loaded.
|
Style.Builder |
withImage(java.lang.String id,
android.graphics.Bitmap image,
java.util.List<ImageStretches> stretchX,
java.util.List<ImageStretches> stretchY,
ImageContent content) |
Will add the image when the map style has loaded.
|
Style.Builder |
withImage(java.lang.String id,
android.graphics.drawable.Drawable drawable) |
Will add the drawable as image when the map style has loaded.
|
Style.Builder |
withImage(java.lang.String id,
android.graphics.drawable.Drawable drawable,
boolean sdf) |
Will add the drawable as image when the map style has loaded.
|
Style.Builder |
withImage(java.lang.String id,
android.graphics.drawable.Drawable drawable,
boolean sdf,
java.util.List<ImageStretches> stretchX,
java.util.List<ImageStretches> stretchY,
ImageContent content) |
Will add the drawable as image when the map style has loaded.
|
Style.Builder |
withImage(java.lang.String id,
android.graphics.drawable.Drawable drawable,
java.util.List<ImageStretches> stretchX,
java.util.List<ImageStretches> stretchY,
ImageContent content) |
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,
java.lang.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,
java.lang.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.
|
@Deprecated @NonNull public Style.Builder fromUrl(@NonNull java.lang.String url)
fromUri(String)
insteadWill 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 TrimbleMaps account.
user
is your username. style
is the ID of your custom
style created in TrimbleMaps 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.MOBILE_DEFAULT
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 provide an Style.OnStyleLoaded
callback when setting the style on TrimbleMapsMap.
MapView.OnDidFailLoadingMapListener
callback
will be triggered.url
- The URL of the map styleStyle
@NonNull public Style.Builder fromUri(@NonNull java.lang.String uri)
Will loads a new map style asynchronous from the specified URI.
uri
can take the following forms:
Style#StyleUrl
: load one of the bundled styles in Style
.mapbox://styles/<user>/<style>
:
loads the style from a TrimbleMaps account.
user
is your username. style
is the ID of your custom
style created in TrimbleMaps 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.MOBILE_DEFAULT
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 TrimbleMapsMap.setStyle(String, OnStyleLoaded)
instead.
MapView.OnDidFailLoadingMapListener
callback
will be triggered.uri
- The URI of the map styleStyle
@NonNull public Style.Builder fromJson(@NonNull java.lang.String styleJson)
If the style fails to load or an invalid style URI 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.
@NonNull public Style.Builder withSource(@NonNull Source source)
source
- the source to add@NonNull public Style.Builder withSources(@NonNull Source... sources)
sources
- the sources to add@NonNull public Style.Builder withLayer(@NonNull Layer layer)
layer
- the layer to be added@NonNull public Style.Builder withLayers(@NonNull Layer... layers)
layers
- the layers to be added@NonNull public Style.Builder withLayerAt(@NonNull Layer layer, int index)
layer
- the layer to be added@NonNull public Style.Builder withLayerAbove(@NonNull Layer layer, @NonNull java.lang.String aboveLayerId)
layer
- the layer to be added@NonNull public Style.Builder withLayerBelow(@NonNull Layer layer, @NonNull java.lang.String belowLayerId)
layer
- the layer to be added@NonNull public Style.Builder withTransition(@NonNull TransitionOptions transition)
transition
- the transition to be added@NonNull public Style.Builder withImage(@NonNull java.lang.String id, @NonNull android.graphics.drawable.Drawable drawable)
id
- the id for the imagedrawable
- the drawable to be converted and added@NonNull public Style.Builder withImage(@NonNull java.lang.String id, @NonNull android.graphics.drawable.Drawable drawable, @NonNull java.util.List<ImageStretches> stretchX, @NonNull java.util.List<ImageStretches> stretchY, @Nullable ImageContent content)
id
- the id for the imagedrawable
- the drawable to be converted and addedstretchX
- image stretch areas for x axixstretchY
- image stretch areas for y axixcontent
- image content for text to fit@NonNull public Style.Builder withDrawableImages(@NonNull android.util.Pair<java.lang.String,android.graphics.drawable.Drawable>... values)
values
- pairs, where first is the id for te image and second is the drawable@NonNull public Style.Builder withImage(@NonNull java.lang.String id, @NonNull android.graphics.Bitmap image)
id
- the id for the imageimage
- the image to be added@NonNull public Style.Builder withImage(@NonNull java.lang.String id, @NonNull android.graphics.Bitmap image, @NonNull java.util.List<ImageStretches> stretchX, @NonNull java.util.List<ImageStretches> stretchY, @Nullable ImageContent content)
id
- the id for the imageimage
- the image to be addedstretchX
- image stretch areas for x axixstretchY
- image stretch areas for y axixcontent
- image content for text to fit@NonNull public Style.Builder withBitmapImages(@NonNull android.util.Pair<java.lang.String,android.graphics.Bitmap>... values)
values
- pairs, where first is the id for te image and second is the bitmap@NonNull public Style.Builder withImage(@NonNull java.lang.String id, @NonNull android.graphics.drawable.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 image@NonNull public Style.Builder withImage(@NonNull java.lang.String id, @NonNull android.graphics.drawable.Drawable drawable, boolean sdf, @NonNull java.util.List<ImageStretches> stretchX, @NonNull java.util.List<ImageStretches> stretchY, @Nullable ImageContent content)
id
- the id for the imagedrawable
- the drawable to be converted and addedsdf
- the flag indicating image is an SDF or template imagestretchX
- image stretch areas for x axixstretchY
- image stretch areas for y axixcontent
- image content for text to fit@NonNull public Style.Builder withDrawableImages(boolean sdf, @NonNull android.util.Pair<java.lang.String,android.graphics.drawable.Drawable>... 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 drawable@NonNull public Style.Builder withImage(@NonNull java.lang.String id, @NonNull android.graphics.Bitmap image, boolean sdf)
id
- the id for the imageimage
- the image to be addedsdf
- the flag indicating image is an SDF or template image@NonNull public Style.Builder withImage(@NonNull java.lang.String id, @NonNull android.graphics.Bitmap image, boolean sdf, @NonNull java.util.List<ImageStretches> stretchX, @NonNull java.util.List<ImageStretches> stretchY, @Nullable ImageContent content)
id
- the id for the imageimage
- the image to be addedsdf
- the flag indicating image is an SDF or template imagestretchX
- image stretch areas for x axixstretchY
- image stretch areas for y axixcontent
- image content for text to fit@NonNull public Style.Builder withBitmapImages(boolean sdf, @NonNull android.util.Pair<java.lang.String,android.graphics.Bitmap>... 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 bitmappublic java.lang.String getUri()
public java.lang.String getJson()
public java.util.List<Source> getSources()
public java.util.List<Style.Builder.LayerWrapper> getLayers()
public java.util.List<Style.Builder.ImageWrapper> getImages()