Class WebTiledLayer

All Implemented Interfaces:
RemoteResource, LayerContent, Loadable
Direct Known Subclasses:
OpenStreetMapLayer

public class WebTiledLayer extends ServiceImageTiledLayer
A layer that can visualize image tiles from non-ArcGIS web services or local tile caches based on a URI template.

This layer provides a simple way to integrate non-ArcGIS Services as a layer in a map. The URL template usually follows a pattern similar to https://{subDomain}.server.org/path/{level}/{col}/{row}.png , where:

  • subDomain is one of the strings in the subDomains list
  • level corresponds to a zoom level
  • col represents the column of the tile
  • row represents the row of the tile.
The URL should be arranged to reflect how the tiles are organized in the cache or on the server, and can point to a web server (https://) or to a local file cache (%file://}).

The tiles retrieved by this class are accessed directly by URL. Because the service is only providing images, you are responsible for manually setting the attribution text on the map or scene view.

To create a custom service tiled layer whose URL follows the above pattern (or a similar pattern), you can extend this class. Alternatively, you can extend the super class ServiceImageTiledLayer , in which you implement a required method to set the request information for a given Level of Detail (LOD) , column, and row. Extending WebTiledLayer, however, has no such requirement.

An exception will be thrown when attempting to load a layer with invalid URI template.

If TileInfo is not specified, tiles are assumed to be in the OpenStreetMap tiling scheme, with 256x256 PNG tiles at 96 DPI, the WebMercator projection, and a FullExtent of [-180, -85.0511, 180, 85.051].

Functional characteristics

Specifying sub-domains from which the layer will request tiles allows the load to be more evenly distributed among servers.

Performance characteristics

Web tiled layer requires a connection to the service at all times. Performance is similar to other raster tile layers.

Example for working with a WebTiledLayer

 WebTiledLayer webTiledLayer = new WebTiledLayer(
   "http://{subDomain}.tile.opencyclemap.org/cycle/{level}/{col}/{row}.png", // templateUri
   Arrays.asList("a", "b") // subDomains
 );
 
 webTiledLayer.addDoneLoadingListener(new Runnable() {
   public void run() {
     if (webTiledLayer.getLoadStatus() == LoadStatus.LOADED) {
       // work with the layer here
     }
   }
 });
 
 map.getOperationalLayers().add(webTiledLayer);
 
 mapView.setMap(map);
 
The layer is loaded when displayed in a MapView or SceneView if using the layer without a MapView or SceneView, call the Layer.loadAsync() method. Use the layer done loading event to determine when the layer is ready, and check the load status before using the layer.
Since:
100.1.0
See Also:
  • Constructor Details

    • WebTiledLayer

      public WebTiledLayer(String templateUri)
      Creates a web tiled layer with the given URI template.

      Use this constructor to create a WebTiledLayer to integrate non-ArcGIS Services as a layer in a map. Since this constructor does not require an explicit TileInfo argument, the max LOD will be 23 (approximate scale of 70 and resolution of 1.86 cm/pixel). The URI template usually follows a pattern similar to https://server.org/path/{level}/{col}/{row}.png, where:

      • "level" corresponds to a zoom level.
      • "col" represents the column of the tile.
      • "row" represents the row of the tile.

      The URI should be arranged to reflect how the tiles are arranged in the cache or on the server, and can point to a web server (https://) or to a local file cache (file://).

      The tiles are assumed to be in the OpenStreetMap tiling scheme, with 256x256 PNG tiles at 96 DPI, the webMercator projection, and an extent of [-180, -85.0511, 180, 85.051].

      TileInfo and Layer.getFullExtent() are set to OpenStreetMap-compatible defaults, and getSubDomains() is left empty.

      Parameters:
      templateUri - a template Uri for tile requests
      Throws:
      IllegalArgumentException - if templateUri is null or empty
      Since:
      100.1.0
    • WebTiledLayer

      public WebTiledLayer(String templateUri, Iterable<String> subDomains)
      Creates a web tiled layer with the given URI template and collection of sub-domains.

      Use this constructor to create a WebTiledLayer to integrate non-ArcGIS Services as a layer in a map. Since this constructor does not require an explicit TileInfo argument, the max LOD will be 23 (approximate scale of 70 and resolution of 1.86 cm/pixel). The URI template usually follows a pattern similar to https://{subDomain}.server.org/path/{level}/{col}/{row}.png, where:

      • "subDomain" is one of the strings in the subDomains collection
      • "level" corresponds to a zoom level
      • "col" represents the column of the tile
      • "row" represents the row of the tile

      The subDomains collection must contain at least 1 string value to use the "subDomain" key in the URI template. The URI should be arranged to reflect how the tiles are arranged in the cache or on the server, and can point to a web server (https://) or to a local file cache (file://).

      The tiles are assumed to be in the OpenStreetMap tiling scheme, with 256x256 PNG tiles at 96 DPI, the webMercator projection, and an extent of [-180, -85.0511, 180, 85.051]. TileInfo and Layer.getFullExtent() are set to OpenStreetMap-compatible defaults.

      Parameters:
      templateUri - the template Uri
      subDomains - a collection of strings listing available sub-domains
      Throws:
      IllegalArgumentException - if templateUri is null or empty
      Since:
      100.1.0
    • WebTiledLayer

      public WebTiledLayer(String templateUri, TileInfo tileInfo, Envelope fullExtent)
      Creates a web tiled layer with the specified URI template, tiling scheme information, and extent.

      Use this constructor to create a WebTiledLayer to integrate non-ArcGIS Services as a layer in a map. The URI template usually follows a pattern similar to https://server.org/path/{level}/{col}/{row}.png, where:

      • "level" corresponds to a zoom level
      • "col" represents the column of the tile
      • "row" represents the row of the tile

      The URI should be arranged to reflect how the tiles are arranged in the cache or on the server, and can point to a web server (https://) or to a local file cache (file://). getSubDomains() is left empty.

      Parameters:
      templateUri - the template Uri
      tileInfo - tile info that specifies details about the tiles, such as DPI, tile size, etc.; can be null
      fullExtent - defines the full extent of the tiles, can be null
      Throws:
      IllegalArgumentException - if templateUri is null or empty
      Since:
      100.1.0
    • WebTiledLayer

      public WebTiledLayer(String templateUri, Iterable<String> subDomains, TileInfo tileInfo, Envelope fullExtent)
      Creates a web tiled layer with the given URI template, sub-domain collection, tiling scheme information, and extent.

      Use this constructor to create a WebTiledLayer to integrate non-ArcGIS Services as a layer in a map. The URI template usually follows a pattern similar to https://{subDomain}.server.org/path/{level}/{col}/{row}.png, where:

      • "subDomain" is one of the strings in the subDomains list.
      • "level" corresponds to a zoom level.
      • "col" represents the column of the tile.
      • "row" represents the row of the tile.

      The subDomains collection must contain at least 1 string value to use the "subDomain" key in the URI template. The URI should be arranged to reflect how the tiles are arranged in the cache or on the server, and can point to a web server (https://) or to a local file cache (file://).

      Parameters:
      templateUri - the template Uri
      subDomains - a collection of strings listing available sub-domains
      tileInfo - tile info that specifies details about the tiles, such as DPI, tile size, etc. Can be null.
      fullExtent - defines the full extent of the tiles. Can be null.
      Throws:
      IllegalArgumentException - if templateUri is null or empty
      Since:
      100.1.0
  • Method Details

    • setAttribution

      public void setAttribution(String attribution)
      Sets the attribution.
      Parameters:
      attribution - the attribution text
      Since:
      100.1.0
    • getTemplateUri

      public String getTemplateUri()
      The URI template for this web tiled layer.

      The template uses the {subDomain} (optional), {level}, {row}, and {col} keys to note how the layer should construct the URI for requesting individual tiles. The URI should be arranged to reflect how the tiles are arranged in the cache or on the server, and can point to a web server (https://) or to a local file cache (file://). Note: the value of getTemplateUri() cannot be changed after this layer was loaded.

      Returns:
      the template Uri used to create this WebTiledLayer
      Since:
      100.1.0
    • getSubDomains

      public List<String> getSubDomains()
      Gets the collection of sub-domains that can be used for the "{subDomain}" key in the getTemplateUri().

      At least one sub-domain must be provided if the WebTiledLayer.templateUriProperty() contains a {subDomain} key. Note: the value of getSubDomains() cannot be changed after this layer was loaded.

      Returns:
      the collection of sub-domains that can be used for the "{subDomain}" key in the WebTiledLayer.templateUriProperty()
      Since:
      100.1.0
    • getUri

      public String getUri()
      Gets a null URI String indicating no specific endpoint URI associated with this WebTiledLayer.
      Returns:
      a null URI String
      Since:
      100.1.0
      See Also:
    • getTileUrl

      protected String getTileUrl(TileKey tileKey)
      Description copied from class: ServiceImageTiledLayer
      Gets the url to be used to request a tile given the tile key. Note it's important this method does not do any time-consuming work, otherwise tiles may be very slow to display.
      Specified by:
      getTileUrl in class ServiceImageTiledLayer
      Parameters:
      tileKey - tile key for which the url is to be returned
      Returns:
      the url to be used to request a tile, can't be null or empty
    • copy

      public WebTiledLayer copy()
      Creates a deep copy of this WebTiledLayer instance.
      Returns:
      a deep copy of this WebTiledLayer instance, which means that copies of all fields of this layer are made including its loading state
      Since:
      100.1.0