Class WebTiledLayer

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

    public class WebTiledLayer
    extends ServiceImageTiledLayer
    Defines an extensible tiled layer that requests images from a tiled image server based on a URI template. It provides a simple way to integrate non-ArcGIS Services as a layer in a map.

    The template URI usually follows a pattern similar to "http://{subDomain}.server.org/path/{level}/{col}/{row}.png", where:

    • subDomain is one of the available strings in the subDomains list
    • level corresponds to a zoom level
    • col represents the column of a tile
    • row represents the row of a tile
    The subDomains list must have at least 1 string value to use the "subDomain" key in the template URI. 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 (http://) or to a local file cache (file://). These placeholders that are indicated by a name surrounded by a {} in the template URI are replaced to generate an endpoint to fetch a tile.

    A custom service tiled layer whose URI follows the above pattern or similar pattern can be created by extending this class. Alternatively you can create a subclass of ServiceImageTiledLayer and override ServiceImageTiledLayer.getTileUrl(TileKey) which you do not need to if you extend WebTiledLayer.

    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 view; if using the layer without a view, 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:
    ServiceImageTiledLayer.getTileUrl(TileKey)
    • Constructor Detail

      • WebTiledLayer

        public WebTiledLayer​(String templateUri)
        Creates a new WebTiled layer from a template Uri.
        Parameters:
        templateUri - the template Uri
        Throws:
        IllegalArgumentException - if templateUri is null or empty
        Since:
        100.1.0
      • WebTiledLayer

        public WebTiledLayer​(String templateUri,
                             Iterable<String> subDomains)
        Creates a new WebTiled layer from a template Uri and sub domains.
        Parameters:
        templateUri - the template Uri
        subDomains - sub domains to be used to replace the {subDomain} placeholder in the templateUri, can be null
        Throws:
        IllegalArgumentException - if templateUri is null or empty
        Since:
        100.1.0
      • WebTiledLayer

        public WebTiledLayer​(String templateUri,
                             TileInfo tileInfo,
                             Envelope fullExtent)
        Creates a new WebTiled layer from a template Uri, tile info and full extent.
        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 new WebTiled layer from a template Uri, sub domains, tile info and full extent.
        Parameters:
        templateUri - the template Uri
        subDomains - sub domains to be used to replace the {subDomain} placeholder in the templateUri, can be null
        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 Detail

      • setAttribution

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

        public String getTemplateUri()
        Gets the template Uri used to create this WebTiledLayer.
        Returns:
        the template Uri used to create this WebTiledLayer
        Since:
        100.1.0
      • getSubDomains

        public List<String> getSubDomains()
        Gets the sub domains used to create this WebTiledLayer.
        Returns:
        an unmodifiable list of the sub domains used to create this WebTiledLayer
        Since:
        100.1.0
      • getUri

        public String getUri()
        Throws UnsupportedOperationException.
        Returns:
        the URI of this RemoteResource
        Throws:
        UnsupportedOperationException - always throws this exception
        Since:
        100.1.0
      • 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