Class Style.Builder

java.lang.Object
com.trimblemaps.mapsdk.maps.Style.Builder
Enclosing class:
Style

public static class Style.Builder extends Object
Builder for composing a style object.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • fromUrl

      @Deprecated @NonNull public Style.Builder fromUrl(@NonNull String url)
      Deprecated.
      use fromUri(String) instead

      Will loads a new map style asynchronous from the specified URL.

      url can take the following forms:
      • 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.

      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.

      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.
      Parameters:
      url - The URL of the map style
      Returns:
      this
      See Also:
    • fromUri

      @NonNull public Style.Builder fromUri(@NonNull String uri)

      Will loads a new map style asynchronous from the specified URI.

      uri can take the following forms:
      • 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.

      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.

      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.
      Parameters:
      uri - The URI of the map style
      Returns:
      this
      See Also:
    • fromJson

      @NonNull public Style.Builder fromJson(@NonNull String styleJson)
      Will load a new map style from a json string.

      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.

      Returns:
      this
    • withSource

      @NonNull public Style.Builder withSource(@NonNull Source source)
      Will add the source when map style has loaded.
      Parameters:
      source - the source to add
      Returns:
      this
    • withSources

      @NonNull public Style.Builder withSources(@NonNull Source... sources)
      Will add the sources when map style has loaded.
      Parameters:
      sources - the sources to add
      Returns:
      this
    • withLayer

      @NonNull public Style.Builder withLayer(@NonNull Layer layer)
      Will add the layer when the style has loaded.
      Parameters:
      layer - the layer to be added
      Returns:
      this
    • withLayers

      @NonNull public Style.Builder withLayers(@NonNull Layer... layers)
      Will add the layers when the style has loaded.
      Parameters:
      layers - the layers to be added
      Returns:
      this
    • withLayerAt

      @NonNull public Style.Builder withLayerAt(@NonNull Layer layer, int index)
      Will add the layer when the style has loaded at a specified index.
      Parameters:
      layer - the layer to be added
      Returns:
      this
    • withLayerAbove

      @NonNull public Style.Builder withLayerAbove(@NonNull Layer layer, @NonNull String aboveLayerId)
      Will add the layer when the style has loaded above a specified layer id.
      Parameters:
      layer - the layer to be added
      Returns:
      this
    • withLayerBelow

      @NonNull public Style.Builder withLayerBelow(@NonNull Layer layer, @NonNull String belowLayerId)
      Will add the layer when the style has loaded below a specified layer id.
      Parameters:
      layer - the layer to be added
      Returns:
      this
    • withTransition

      @NonNull public Style.Builder withTransition(@NonNull TransitionOptions transition)
      Will add the transition when the map style has loaded.
      Parameters:
      transition - the transition to be added
      Returns:
      this
    • withImage

      @NonNull public Style.Builder withImage(@NonNull String id, @NonNull android.graphics.drawable.Drawable drawable)
      Will add the drawable as image when the map style has loaded.
      Parameters:
      id - the id for the image
      drawable - the drawable to be converted and added
      Returns:
      this
    • withImage

      @NonNull public Style.Builder withImage(@NonNull String id, @NonNull android.graphics.drawable.Drawable drawable, @NonNull List<ImageStretches> stretchX, @NonNull List<ImageStretches> stretchY, @Nullable ImageContent content)
      Will add the drawable as image when the map style has loaded.
      Parameters:
      id - the id for the image
      drawable - the drawable to be converted and added
      stretchX - image stretch areas for x axix
      stretchY - image stretch areas for y axix
      content - image content for text to fit
      Returns:
      this
    • withDrawableImages

      @NonNull public Style.Builder withDrawableImages(@NonNull android.util.Pair<String,android.graphics.drawable.Drawable>... values)
      Will add the drawables as images when the map style has loaded.
      Parameters:
      values - pairs, where first is the id for te image and second is the drawable
      Returns:
      this
    • withImage

      @NonNull public Style.Builder withImage(@NonNull String id, @NonNull android.graphics.Bitmap image)
      Will add the image when the map style has loaded.
      Parameters:
      id - the id for the image
      image - the image to be added
      Returns:
      this
    • withImage

      @NonNull public Style.Builder withImage(@NonNull String id, @NonNull android.graphics.Bitmap image, @NonNull List<ImageStretches> stretchX, @NonNull List<ImageStretches> stretchY, @Nullable ImageContent content)
      Will add the image when the map style has loaded.
      Parameters:
      id - the id for the image
      image - the image to be added
      stretchX - image stretch areas for x axix
      stretchY - image stretch areas for y axix
      content - image content for text to fit
      Returns:
      this
    • withBitmapImages

      @NonNull public Style.Builder withBitmapImages(@NonNull android.util.Pair<String,android.graphics.Bitmap>... values)
      Will add the images when the map style has loaded.
      Parameters:
      values - pairs, where first is the id for te image and second is the bitmap
      Returns:
      this
    • withImage

      @NonNull public Style.Builder withImage(@NonNull String id, @NonNull android.graphics.drawable.Drawable drawable, boolean sdf)
      Will add the drawable as image when the map style has loaded.
      Parameters:
      id - the id for the image
      drawable - the drawable to be converted and added
      sdf - the flag indicating image is an SDF or template image
      Returns:
      this
    • withImage

      @NonNull public Style.Builder withImage(@NonNull String id, @NonNull android.graphics.drawable.Drawable drawable, boolean sdf, @NonNull List<ImageStretches> stretchX, @NonNull List<ImageStretches> stretchY, @Nullable ImageContent content)
      Will add the drawable as image when the map style has loaded.
      Parameters:
      id - the id for the image
      drawable - the drawable to be converted and added
      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
      Returns:
      this
    • withDrawableImages

      @NonNull public Style.Builder withDrawableImages(boolean sdf, @NonNull android.util.Pair<String,android.graphics.drawable.Drawable>... values)
      Will add the drawables as images when the map style has loaded.
      Parameters:
      sdf - the flag indicating image is an SDF or template image
      values - pairs, where first is the id for te image and second is the drawable
      Returns:
      this
    • withImage

      @NonNull public Style.Builder withImage(@NonNull String id, @NonNull android.graphics.Bitmap image, boolean sdf)
      Will add the image when the map style has loaded.
      Parameters:
      id - the id for the image
      image - the image to be added
      sdf - the flag indicating image is an SDF or template image
      Returns:
      this
    • withImage

      @NonNull public Style.Builder withImage(@NonNull String id, @NonNull android.graphics.Bitmap image, boolean sdf, @NonNull List<ImageStretches> stretchX, @NonNull List<ImageStretches> stretchY, @Nullable ImageContent content)
      Will add the image when the map style has loaded.
      Parameters:
      id - the id for the image
      image - the image to be added
      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
      Returns:
      this
    • withBitmapImages

      @NonNull public Style.Builder withBitmapImages(boolean sdf, @NonNull android.util.Pair<String,android.graphics.Bitmap>... values)
      Will add the images when the map style has loaded.
      Parameters:
      sdf - the flag indicating image is an SDF or template image
      values - pairs, where first is the id for te image and second is the bitmap
      Returns:
      this
    • getUri

      public String getUri()
    • getJson

      public String getJson()
    • getSources

      public List<Source> getSources()
    • getLayers

      public List<Style.Builder.LayerWrapper> getLayers()
    • getImages

      public List<Style.Builder.ImageWrapper> getImages()