Class WebTiledLayer

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

    public class WebTiledLayer
    extends ServiceImageTiledLayer
    A layer that requests images from a tiled image server based on a URL template.

    It 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 template URI.

    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

    Tiles are fetched on demand using the specified URL template. Tiles are typically prerendered (cached) on the server but may be generated on demand by some services. Web tiled layers do not support identify, query, selection, or time.

    Specifying subdomains 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:
    Layer, 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 https://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 (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 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 https://{subDomain}.server.org/path/{level}/{col}/{row}.png, where "subDomain" is one of the available strings in the sub_domains iterable, "level" corresponds to a zoom level, "col" represents the tile column, and "row" represents the tile row. The "sub_domains" iterable 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 (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 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 https://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 (https://) 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 https://{subDomain}.server.org/path/{level}/{col}/{row}.png, where "subDomain" is one of the available strings in the sub_domains iterable, "level" corresponds to a zoom level, "col" represents the tile column, and "row" represents the tile row. The "sub_domains" iterable must have 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 (https://) 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()
        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:
        getTemplateUri()
      • 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