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​(java.lang.String templateUri)
        Creates a new WebTiledLayer object from a template Uri.

        Use this constructor to create a WebTiledLayer object which provides a simple way to integrate non-ArcGIS Services as a layer in a map. Since an explicit TileInfo argument is not part of this constructor, the max LOD will be 23 (approximate scale of 70 and resolution of 1.86 cm/pixel). The template URI usually follows a pattern similar to http://server.org/path/{level}/{col}/{row}.png, where "level" corresponds to a zoom level, "col" represents the tile column, and "row" represents the tile row. This URI should be arranged to reflect how the tiles are arranged in the cache or on the server. This URI can point to a web server (http://) 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 a fullExtents of [-180, -85.0511, 180, 85.051].

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

        public WebTiledLayer​(java.lang.String templateUri,
                             java.lang.Iterable<java.lang.String> subDomains)
        Creates a new WebTiledLayer object from a template Uri and subdomains.

        Use this constructor to create a WebTiledLayer object, which provides a simple way to integrate non-ArcGIS Services as a layer in a map. Since an explicit TileInfo argument is not part of this constructor, the max LOD will be 23 (approximate scale of 70 and resolution of 1.86 cm/pixel). 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 sub_domains vector, "level" corresponds to a zoom level, "col" represents the tile column, and "row" represents the tile row. The "sub_domains" vector must 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://). The tiles are assumed to be in the OpenStreetMap tiling scheme, with 256x256 PNG tiles at 96 DPI, the webMercator projection, and a fullExtents of [-180, -85.0511, 180, 85.051].

        Parameters:
        templateUri - the template Uri
        subDomains - sub domains to be used to replace the {subDomain} placeholder in the templateUri. Can be null.
        Throws:
        java.lang.IllegalArgumentException - if templateUri is null or empty
        Since:
        100.1.0
      • WebTiledLayer

        public WebTiledLayer​(java.lang.String templateUri,
                             TileInfo tileInfo,
                             Envelope fullExtent)
        Creates a new WebTiled layer from a template Uri, tile info and full extent.

        Creating a WebTileLayer object 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://server.org/path/{level}/{col}/{row}.png, "level" corresponds to a zoom level, "col" represents the tile column, and "row" represents the tile row. This URI should be arranged to reflect how the tiles are arranged in the cache or on the server. This URI can point to a web server (http://) or to a local file cache (file://).

        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:
        java.lang.IllegalArgumentException - if templateUri is null or empty
        Since:
        100.1.0
      • WebTiledLayer

        public WebTiledLayer​(java.lang.String templateUri,
                             java.lang.Iterable<java.lang.String> subDomains,
                             TileInfo tileInfo,
                             Envelope fullExtent)
        Creates a new WebTiled layer from a template Uri, sub domains, tile info and full extent.

        Use this function to create a WebTileLayer object, which 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 sub_domains vector, "level" corresponds to a zoom level, "col" represents the tile column, and "row" represents the tile row. The "sub_domains" vector must at least 1 string value to use the "subDomain" key in the template URI. This 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://).

        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:
        java.lang.IllegalArgumentException - if templateUri is null or empty
        Since:
        100.1.0
    • Method Detail

      • setAttribution

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

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

        protected java.lang.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