Class Style

java.lang.Object
com.trimblemaps.mapsdk.maps.Style

public class Style extends Object
The proxy object for current map 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.

  • Method Details

    • getUrl

      @NonNull @Deprecated public String getUrl()
      Deprecated.
      use getUri() instead
      Returns the current style url.
      Returns:
      the style url
    • getUri

      @NonNull public String getUri()
      Returns the current style uri.
      Returns:
      the style uri
    • getJson

      @NonNull public String getJson()
      Returns the current style json.
      Returns:
      the style json
    • getSources

      @NonNull public List<Source> getSources()
      Retrieve all the sources in the style
      Returns:
      all the sources in the current style
    • addSource

      public void addSource(@NonNull Source source)
      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

      @Nullable public Source getSource(String id)
      Retrieve a source by id
      Parameters:
      id - the source's id
      Returns:
      the source if present in the current style
    • getSourceAs

      @Nullable public <T extends Source> T getSourceAs(@NonNull String sourceId)
      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

      public boolean removeSource(@NonNull String sourceId)
      Removes the source from the style.
      Parameters:
      sourceId - the source to remove
      Returns:
      true if the source was removed, false otherwise
    • removeSource

      public boolean removeSource(@NonNull Source source)
      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

      public void addLayer(@NonNull Layer layer)
      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

      public void addLayerBelow(@NonNull Layer layer, @NonNull String below)
      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
      below - the layer id to add this layer before
    • addLayerAbove

      public void addLayerAbove(@NonNull Layer layer, @NonNull String above)
      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
      above - the layer id to add this layer above
    • addLayerAt

      public void addLayerAt(@NonNull Layer layer, @IntRange(from=0L) int index)
      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 add
      index - the index to insert the layer at
    • getLayer

      @Nullable public Layer getLayer(@NonNull String id)
      Get the layer by id
      Parameters:
      id - the layer's id
      Returns:
      the layer, if present in the style
    • getLayerAs

      @Nullable public <T extends Layer> T getLayerAs(@NonNull String layerId)
      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

      @NonNull public List<Layer> getLayers()
      Retrieve all the layers in the style
      Returns:
      all the layers in the current style
    • removeLayer

      public boolean removeLayer(@NonNull String layerId)
      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

      public boolean removeLayer(@NonNull Layer layer)
      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

      public void addImage(@NonNull String name, @NonNull android.graphics.Bitmap image)
      Adds an image to be used in the map's style
      Parameters:
      name - the name of the image
      image - 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 image
      image - the pre-multiplied Bitmap
      stretchX - image stretch areas for x axix
      stretchY - image stretch areas for y axix
      content - image content for text to fit
    • addImage

      public void addImage(@NonNull String name, @NonNull android.graphics.drawable.Drawable drawable)
      Adds an drawable to be converted into a bitmap to be used in the map's style
      Parameters:
      name - the name of the image
      drawable - 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 image
      drawable - the drawable instance to convert
      stretchX - image stretch areas for x axix
      stretchY - image stretch areas for y axix
      content - image content for text to fit
    • addImage

      public void addImage(@NonNull String name, @NonNull android.graphics.Bitmap bitmap, boolean sdf)
      Adds an image to be used in the map's style
      Parameters:
      name - the name of the image
      bitmap - the pre-multiplied Bitmap
      sdf - 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 image
      bitmap - the pre-multiplied Bitmap
      sdf - the flag indicating image is an SDF or template image
      stretchX - image stretch areas for x axix
      stretchY - image stretch areas for y axix
      content - image content for text to fit
    • addImageAsync

      public void addImageAsync(@NonNull String name, @NonNull android.graphics.Bitmap image)
      Adds an image asynchronously, to be used in the map's style.
      Parameters:
      name - the name of the image
      image - 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 image
      image - the pre-multiplied Bitmap
      stretchX - image stretch areas for x axix
      stretchY - image stretch areas for y axix
      content - 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 image
      drawable - 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 image
      drawable - the drawable instance to convert
      stretchX - image stretch areas for x axix
      stretchY - image stretch areas for y axix
      content - 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 image
      bitmap - the pre-multiplied Bitmap
      sdf - 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 image
      bitmap - the pre-multiplied Bitmap
      sdf - the flag indicating image is an SDF or template image
      stretchX - image stretch areas for x axix
      stretchY - image stretch areas for y axix
      content - image content for text to fit
    • addImages

      public void addImages(@NonNull HashMap<String,android.graphics.Bitmap> images)
      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 add
      stretchX - image stretch areas for x axix
      stretchY - image stretch areas for y axix
      content - image content for text to fit
    • addImages

      public void addImages(@NonNull HashMap<String,android.graphics.Bitmap> images, boolean sdf)
      Adds images to be used in the map's style.
      Parameters:
      images - the map of images to add
      sdf - 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 add
      sdf - the flag indicating image is an SDF or template image
      stretchX - image stretch areas for x axix
      stretchY - image stretch areas for y axix
      content - image content for text to fit
    • addImagesAsync

      public void addImagesAsync(@NonNull HashMap<String,android.graphics.Bitmap> images)
      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 add
      stretchX - image stretch areas for x axix
      stretchY - image stretch areas for y axix
      content - image content for text to fit
    • addImagesAsync

      public void addImagesAsync(@NonNull HashMap<String,android.graphics.Bitmap> images, boolean sdf)
      Adds images asynchronously, to be used in the map's style.
      Parameters:
      images - the map of images to add
      sdf - 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 add
      sdf - the flag indicating image is an SDF or template image
      stretchX - image stretch areas for x axix
      stretchY - image stretch areas for y axix
      content - image content for text to fit
    • removeImage

      public void removeImage(@NonNull String name)
      Removes an image from the map's style.
      Parameters:
      name - the name of the image to remove
    • getImage

      @Nullable public android.graphics.Bitmap getImage(@NonNull String id)
      Get an image from the map's style using an id.
      Parameters:
      id - the id of the image
      Returns:
      the image bitmap
    • setTransition

      public void setTransition(@NonNull TransitionOptions transitionOptions)

      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

      @NonNull public TransitionOptions 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.enablePlacementTransitions equal to false into setTransition(TransitionOptions).

      Both TransitionOptions.duration and TransitionOptions.delay will also change the behavior of the symbols fade in/out animation if the placement transition is enabled.

      Returns:
      TransitionOptions the transition options
    • getLight

      @Nullable public Light 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

      public static Image toImage(Style.Builder.ImageWrapper imageWrapper)
    • getPredefinedStyles

      public static DefaultStyle[] getPredefinedStyles()
      Get predefined styles
      Returns:
      The list of predefined styles
    • getPredefinedStyle

      @NonNull public static String getPredefinedStyle(String name)
      Get predefined style by name
      Returns:
      The predefined style definition