Class Style
To create new instances of this object, create a new instance using a Style.Builder and load the style with
TrimbleMapsMap. This object is returned from TrimbleMapsMap.getStyle() once the style
has been loaded by underlying map.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for composing a style object.static interfaceCallback to be invoked when a style has finished loading.static classstatic class -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an image to be used in the map's stylevoidAdds an image to be used in the map's stylevoidaddImage(String name, android.graphics.Bitmap bitmap, boolean sdf, List<ImageStretches> stretchX, List<ImageStretches> stretchY, ImageContent content) Adds an image to be used in the map's stylevoidaddImage(String name, android.graphics.Bitmap image, List<ImageStretches> stretchX, List<ImageStretches> stretchY, ImageContent content) Adds an image to be used in the map's stylevoidAdds an drawable to be converted into a bitmap to be used in the map's stylevoidaddImage(String name, android.graphics.drawable.Drawable drawable, List<ImageStretches> stretchX, List<ImageStretches> stretchY, ImageContent content) Adds an drawable to be converted into a bitmap to be used in the map's stylevoidaddImageAsync(String name, android.graphics.Bitmap image) Adds an image asynchronously, to be used in the map's style.voidaddImageAsync(String name, android.graphics.Bitmap bitmap, boolean sdf) Adds an image asynchronously, to be used in the map's style.voidaddImageAsync(String name, android.graphics.Bitmap bitmap, boolean sdf, List<ImageStretches> stretchX, List<ImageStretches> stretchY, ImageContent content) Adds an image asynchronously, to be used in the map's style.voidaddImageAsync(String name, android.graphics.Bitmap image, List<ImageStretches> stretchX, List<ImageStretches> stretchY, ImageContent content) Adds an image asynchronously, to be used in the map's style.voidaddImageAsync(String name, android.graphics.drawable.Drawable drawable) Adds an drawable asynchronously, to be converted into a bitmap to be used in the map's style.voidaddImageAsync(String name, android.graphics.drawable.Drawable drawable, List<ImageStretches> stretchX, List<ImageStretches> stretchY, ImageContent content) Adds an drawable asynchronously, to be converted into a bitmap to be used in the map's style.voidAdds images to be used in the map's style.voidAdds images to be used in the map's style.voidaddImages(HashMap<String, android.graphics.Bitmap> images, boolean sdf, List<ImageStretches> stretchX, List<ImageStretches> stretchY, ImageContent content) Adds images to be used in the map's style.voidaddImages(HashMap<String, android.graphics.Bitmap> images, List<ImageStretches> stretchX, List<ImageStretches> stretchY, ImageContent content) Adds images to be used in the map's style.voidaddImagesAsync(HashMap<String, android.graphics.Bitmap> images) Adds images asynchronously, to be used in the map's style.voidaddImagesAsync(HashMap<String, android.graphics.Bitmap> images, boolean sdf) Adds images asynchronously, to be used in the map's style.voidaddImagesAsync(HashMap<String, android.graphics.Bitmap> images, boolean sdf, List<ImageStretches> stretchX, List<ImageStretches> stretchY, ImageContent content) Adds images asynchronously, to be used in the map's style.voidaddImagesAsync(HashMap<String, android.graphics.Bitmap> images, List<ImageStretches> stretchX, List<ImageStretches> stretchY, ImageContent content) Adds images asynchronously, to be used in the map's style.voidAdds the layer to the map.voidaddLayerAbove(Layer layer, String above) Adds the layer to the map.voidaddLayerAt(Layer layer, int index) Adds the layer to the map at the specified index.voidaddLayerBelow(Layer layer, String below) Adds the layer to the map.voidAdds the source to the map.android.graphics.BitmapGet an image from the map's style using an id.getJson()Returns the current style json.Get the layer by id<T extends Layer>
TgetLayerAs(String layerId) Tries to cast the Layer to T, throws ClassCastException if it's another type.Retrieve all the layers in the stylegetLight()Get the light source used to change lighting conditions on extruded fill layers.static StringgetPredefinedStyle(String name) Get predefined style by namestatic DefaultStyle[]Get predefined stylesRetrieve a source by id<T extends Source>
TgetSourceAs(String sourceId) Tries to cast the Source to T, throws ClassCastException if it's another type.Retrieve all the sources in the styleGet the transition options for style changes.getUri()Returns the current style uri.getUrl()Deprecated.booleanReturns true if the style is fully loaded.voidremoveImage(String name) Removes an image from the map's style.booleanremoveLayer(Layer layer) Removes the layer.booleanremoveLayer(String layerId) Removes the layer.booleanremoveLayerAt(int index) Removes the layer.booleanremoveSource(Source source) Removes the source, preserving the reference for re-usebooleanremoveSource(String sourceId) Removes the source from the style.voidsetTransition(TransitionOptions transitionOptions) Set the transition options for style changes.static ImagetoImage(Style.Builder.ImageWrapper imageWrapper)
-
Method Details
-
getUrl
Deprecated.usegetUri()insteadReturns the current style url.- Returns:
- the style url
-
getUri
Returns the current style uri.- Returns:
- the style uri
-
getJson
Returns the current style json.- Returns:
- the style json
-
getSources
Retrieve all the sources in the style- Returns:
- all the sources in the current style
-
addSource
Adds the source to the map. The source must be newly created and not added to the map before- Parameters:
source- the source to add
-
getSource
Retrieve a source by id- Parameters:
id- the source's id- Returns:
- the source if present in the current style
-
getSourceAs
Tries to cast the Source to T, throws ClassCastException if it's another type.- Type Parameters:
T- the generic type of a Source- Parameters:
sourceId- the id used to look up a layer- Returns:
- the casted Source, null if another type
-
removeSource
Removes the source from the style.- Parameters:
sourceId- the source to remove- Returns:
- true if the source was removed, false otherwise
-
removeSource
Removes the source, preserving the reference for re-use- Parameters:
source- the source to remove- Returns:
- true if the source was removed, false otherwise
-
addLayer
Adds the layer to the map. The layer must be newly created and not added to the map before- Parameters:
layer- the layer to add
-
addLayerBelow
Adds the layer to the map. The layer must be newly created and not added to the map before- Parameters:
layer- the layer to addbelow- the layer id to add this layer before
-
addLayerAbove
Adds the layer to the map. The layer must be newly created and not added to the map before- Parameters:
layer- the layer to addabove- the layer id to add this layer above
-
addLayerAt
Adds the layer to the map at the specified index. The layer must be newly created and not added to the map before- Parameters:
layer- the layer to addindex- the index to insert the layer at
-
getLayer
Get the layer by id- Parameters:
id- the layer's id- Returns:
- the layer, if present in the style
-
getLayerAs
Tries to cast the Layer to T, throws ClassCastException if it's another type.- Type Parameters:
T- the generic attribute of a Layer- Parameters:
layerId- the layer id used to look up a layer- Returns:
- the casted Layer, null if another type
-
getLayers
Retrieve all the layers in the style- Returns:
- all the layers in the current style
-
removeLayer
Removes the layer. Any references to the layer become invalid and should not be used anymore- Parameters:
layerId- the layer to remove- Returns:
- true if the layer was removed, false otherwise
-
removeLayer
Removes the layer. The reference is re-usable after this and can be re-added- Parameters:
layer- the layer to remove- Returns:
- true if the layer was removed, false otherwise
-
removeLayerAt
public boolean removeLayerAt(@IntRange(from=0L) int index) Removes the layer. Any other references to the layer become invalid and should not be used anymore- Parameters:
index- the layer index- Returns:
- true if the layer was removed, false otherwise
-
addImage
Adds an image to be used in the map's style- Parameters:
name- the name of the imageimage- the pre-multiplied Bitmap
-
addImage
public void addImage(@NonNull String name, @NonNull android.graphics.Bitmap image, @NonNull List<ImageStretches> stretchX, @NonNull List<ImageStretches> stretchY, @Nullable ImageContent content) Adds an image to be used in the map's style- Parameters:
name- the name of the imageimage- the pre-multiplied BitmapstretchX- image stretch areas for x axixstretchY- image stretch areas for y axixcontent- image content for text to fit
-
addImage
Adds an drawable to be converted into a bitmap to be used in the map's style- Parameters:
name- the name of the imagedrawable- the drawable instance to convert
-
addImage
public void addImage(@NonNull String name, @NonNull android.graphics.drawable.Drawable drawable, @NonNull List<ImageStretches> stretchX, @NonNull List<ImageStretches> stretchY, @Nullable ImageContent content) Adds an drawable to be converted into a bitmap to be used in the map's style- Parameters:
name- the name of the imagedrawable- the drawable instance to convertstretchX- image stretch areas for x axixstretchY- image stretch areas for y axixcontent- image content for text to fit
-
addImage
Adds an image to be used in the map's style- Parameters:
name- the name of the imagebitmap- the pre-multiplied Bitmapsdf- the flag indicating image is an SDF or template image
-
addImage
public void addImage(@NonNull String name, @NonNull android.graphics.Bitmap bitmap, boolean sdf, @NonNull List<ImageStretches> stretchX, @NonNull List<ImageStretches> stretchY, @Nullable ImageContent content) Adds an image to be used in the map's style- Parameters:
name- the name of the imagebitmap- the pre-multiplied Bitmapsdf- 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
-
addImageAsync
Adds an image asynchronously, to be used in the map's style.- Parameters:
name- the name of the imageimage- the pre-multiplied Bitmap
-
addImageAsync
public void addImageAsync(@NonNull String name, @NonNull android.graphics.Bitmap image, @NonNull List<ImageStretches> stretchX, @NonNull List<ImageStretches> stretchY, @Nullable ImageContent content) Adds an image asynchronously, to be used in the map's style.- Parameters:
name- the name of the imageimage- the pre-multiplied BitmapstretchX- image stretch areas for x axixstretchY- image stretch areas for y axixcontent- image content for text to fit
-
addImageAsync
public void addImageAsync(@NonNull String name, @NonNull android.graphics.drawable.Drawable drawable) Adds an drawable asynchronously, to be converted into a bitmap to be used in the map's style.- Parameters:
name- the name of the imagedrawable- the drawable instance to convert
-
addImageAsync
public void addImageAsync(@NonNull String name, @NonNull android.graphics.drawable.Drawable drawable, @NonNull List<ImageStretches> stretchX, @NonNull List<ImageStretches> stretchY, @Nullable ImageContent content) Adds an drawable asynchronously, to be converted into a bitmap to be used in the map's style.- Parameters:
name- the name of the imagedrawable- the drawable instance to convertstretchX- image stretch areas for x axixstretchY- image stretch areas for y axixcontent- image content for text to fit
-
addImageAsync
public void addImageAsync(@NonNull String name, @NonNull android.graphics.Bitmap bitmap, boolean sdf) Adds an image asynchronously, to be used in the map's style.- Parameters:
name- the name of the imagebitmap- the pre-multiplied Bitmapsdf- the flag indicating image is an SDF or template image
-
addImageAsync
public void addImageAsync(@NonNull String name, @NonNull android.graphics.Bitmap bitmap, boolean sdf, @NonNull List<ImageStretches> stretchX, @NonNull List<ImageStretches> stretchY, @Nullable ImageContent content) Adds an image asynchronously, to be used in the map's style.- Parameters:
name- the name of the imagebitmap- the pre-multiplied Bitmapsdf- 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
-
addImages
Adds images to be used in the map's style.- Parameters:
images- the map of images to add
-
addImages
public void addImages(@NonNull HashMap<String, android.graphics.Bitmap> images, @NonNull List<ImageStretches> stretchX, @NonNull List<ImageStretches> stretchY, @Nullable ImageContent content) Adds images to be used in the map's style.- Parameters:
images- the map of images to addstretchX- image stretch areas for x axixstretchY- image stretch areas for y axixcontent- image content for text to fit
-
addImages
Adds images to be used in the map's style.- Parameters:
images- the map of images to addsdf- the flag indicating image is an SDF or template image
-
addImages
public void addImages(@NonNull HashMap<String, android.graphics.Bitmap> images, boolean sdf, @NonNull List<ImageStretches> stretchX, @NonNull List<ImageStretches> stretchY, @Nullable ImageContent content) Adds images to be used in the map's style.- Parameters:
images- the map of images to addsdf- 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
-
addImagesAsync
Adds images asynchronously, to be used in the map's style.- Parameters:
images- the map of images to add
-
addImagesAsync
public void addImagesAsync(@NonNull HashMap<String, android.graphics.Bitmap> images, @NonNull List<ImageStretches> stretchX, @NonNull List<ImageStretches> stretchY, @Nullable ImageContent content) Adds images asynchronously, to be used in the map's style.- Parameters:
images- the map of images to addstretchX- image stretch areas for x axixstretchY- image stretch areas for y axixcontent- image content for text to fit
-
addImagesAsync
Adds images asynchronously, to be used in the map's style.- Parameters:
images- the map of images to addsdf- the flag indicating image is an SDF or template image
-
addImagesAsync
public void addImagesAsync(@NonNull HashMap<String, android.graphics.Bitmap> images, boolean sdf, @NonNull List<ImageStretches> stretchX, @NonNull List<ImageStretches> stretchY, @Nullable ImageContent content) Adds images asynchronously, to be used in the map's style.- Parameters:
images- the map of images to addsdf- 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
-
removeImage
Removes an image from the map's style.- Parameters:
name- the name of the image to remove
-
getImage
Get an image from the map's style using an id.- Parameters:
id- the id of the image- Returns:
- the image bitmap
-
setTransition
Set the transition options for style changes.
If not set, any changes take effect without animation, besides symbols, which will fade in/out with a default duration after symbol collision detection.To disable symbols fade in/out animation, pass transition options with equal to false.
Both and will also change the behavior of the symbols fade in/out animation if the placement transition is enabled.
- Parameters:
transitionOptions- the transition options
-
getTransition
Get the transition options for style changes.
By default, any changes take effect without animation, besides symbols, which will fade in/out with a default duration after symbol collision detection.To disable symbols fade in/out animation, pass transition options with
TransitionOptions.enablePlacementTransitionsequal to false intosetTransition(TransitionOptions).Both
TransitionOptions.durationandTransitionOptions.delaywill also change the behavior of the symbols fade in/out animation if the placement transition is enabled.- Returns:
- TransitionOptions the transition options
-
getLight
Get the light source used to change lighting conditions on extruded fill layers.- Returns:
- the global light source
-
isFullyLoaded
public boolean isFullyLoaded()Returns true if the style is fully loaded. Returns false if style hasn't been fully loaded or a new style is underway of being loaded.- Returns:
- True if fully loaded, false otherwise
-
toImage
-
getPredefinedStyles
Get predefined styles- Returns:
- The list of predefined styles
-
getPredefinedStyle
Get predefined style by name- Returns:
- The predefined style definition
-
getUri()instead