Class Layer

    • Method Detail

      • getAttribution

        public String getAttribution()
        Gets the attribution for this layer, such as data providers or copyright text.
        Returns:
        the attribution for this layer
        Since:
        100.0.0
      • getDescription

        public String getDescription()
        Gets the description of this layer.
        Returns:
        the description of this layer
        Since:
        100.0.0
      • setDescription

        public void setDescription​(String description)
        Sets the description of this layer.
        Parameters:
        description - the description to set on this layer
        Since:
        100.0.0
      • getFullExtent

        public Envelope getFullExtent()
        Gets the full extent of this layer, which is the extent where all layer data is contained. You can use this to zoom to all features contained in this feature layer. This is calculated from the feature table.
        Returns:
        the full extent of this layer
        Since:
        100.0.0
        See Also:
        FeatureTable.getExtent()
      • getId

        public String getId()
        Returns a string that represents the layer's unique ID in the map. For layers from existing maps, this is set by the authoring application. For layers added to a new map, it is the authoring application's responsibility to set this to a unique value.
        Returns:
        a string containing the ID that uniquely identifies this layer at runtime
        Since:
        100.0.0
        See Also:
        setId(java.lang.String)
      • setId

        public void setId​(String id)
        Sets a string that represents the layer's unique ID in the map. For layers from existing maps, this is set by the authoring application and should not be overwritten. For layers added to a new map, it is the authoring application's responsibility to set this to a unique value.
        Parameters:
        id - the ID to set
        Throws:
        IllegalArgumentException - if id is null
        Since:
        100.0.0
      • getMaxScale

        public double getMaxScale()
        Gets the maximum zoom scale for this layer. This determines the maximum scale level this layer can zoom to.
        Returns:
        the maximum zoom scale to which this layer can zoom
        Since:
        100.0.0
      • setMaxScale

        public void setMaxScale​(double maxScale)
        Sets the maximum zoom scale for this layer. This controls the maximum scale level this layer can zoom to.
        Parameters:
        maxScale - the maximum zoom scale to which this layer can zoom
        Since:
        100.0.0
      • getMinScale

        public double getMinScale()
        Gets the minimum zoom scale for this layer. This determines the minimum scale level this layer can zoom to.
        Returns:
        the minimum scale level this layer can zoom to
        Since:
        100.0.0
      • setMinScale

        public void setMinScale​(double minScale)
        Sets the minimum zoom scale for this layer. This controls the minimum scale level this layer can zoom to.
        Parameters:
        minScale - the minimum scale level this layer can zoom to
        Since:
        100.0.0
      • getName

        public String getName()
        Gets the name of this layer.
        Specified by:
        getName in interface LayerContent
        Returns:
        the name of this layer
        Since:
        100.0.0
      • setName

        public void setName​(String name)
        Sets the name of this layer.
        Parameters:
        name - the name of this layer
        Since:
        100.0.0
      • getOpacity

        public float getOpacity()
        Gets the opacity of this layer.
        Returns:
        The opacity of this layer, which is a value in the range of 0.0 - 1.0, with the default being 1.0 which is fully opaque.
        Since:
        100.0.0
      • setOpacity

        public void setOpacity​(float opacity)
        Sets the opacity of this layer.
        Parameters:
        opacity - the opacity of this layer, which needs to be a value in the range of 0.0 - 1.0, 1.0 being fully opaque
        Since:
        100.0.0
      • getItem

        public Item getItem()
        Gets the Item associated with this layer.
        Returns:
        the associated Item or null if this layer is not associated with an Item
        Since:
        100.0.0
      • getSpatialReference

        public SpatialReference getSpatialReference()
        Gets the spatial reference of this layer.
        Returns:
        the spatial reference of this layer
        Since:
        100.0.0
      • isIdentifyEnabled

        public boolean isIdentifyEnabled()
        Gets whether the layer supports identify.

        If the layer is not loaded this may return false if identify support is determined by metadata that is not yet available.

        Returns:
        true if the layer supports identify, false otherwise
        Since:
        100.2.0
      • canChangeVisibility

        public boolean canChangeVisibility()
        Description copied from interface: LayerContent
        Returns whether or not we can change the visibility of this layer.
        Specified by:
        canChangeVisibility in interface LayerContent
        Returns:
        true if we can change this layer's visibility, false otherwise
      • isVisible

        public boolean isVisible()
        Description copied from interface: LayerContent
        Returns whether this layer is visible or not.
        Specified by:
        isVisible in interface LayerContent
        Returns:
        true if the layer is visible, false otherwise
      • isVisibleAtScale

        public boolean isVisibleAtScale​(double scale)
        Description copied from interface: LayerContent
        Returns whether or not this layer will be visible at the given scale.
        Specified by:
        isVisibleAtScale in interface LayerContent
        Parameters:
        scale - will the layer be visible at this scale?
        Returns:
        true if the layer will be visible at the given scale, false otherwise
      • canShowInLegend

        public boolean canShowInLegend()
        Description copied from interface: LayerContent
        Returns whether or not this layer will be listed in the legend.
        Specified by:
        canShowInLegend in interface LayerContent
        Returns:
        true if this layer will be visible in the legend, false otherwise
      • setCanShowInLegend

        public void setCanShowInLegend​(boolean canShowInLegend)
        Description copied from interface: LayerContent
        Sets whether or not this layer should be visible in the legend.
        Specified by:
        setCanShowInLegend in interface LayerContent
        Parameters:
        canShowInLegend - true to show in the legend, false to omit it from the legend
      • getSubLayerContents

        public ListenableList<LayerContent> getSubLayerContents()
        Description copied from interface: LayerContent
        Returns a list of sub layers, if any. If there are no sub-layers, an empty list will be returned. This list cannot be used to add or remove sub-layers.
        Specified by:
        getSubLayerContents in interface LayerContent
        Returns:
        a read only list of sub-layers, if any
      • getLoadStatus

        public LoadStatus getLoadStatus()
        Description copied from interface: Loadable
        Returns the LoadStatus of the loadable resource.
        Specified by:
        getLoadStatus in interface Loadable
        Returns:
        the LoadStatus of the loadable resource
      • getLoadError

        public ArcGISRuntimeException getLoadError()
        Description copied from interface: Loadable
        Returns the most recent error that was encountered when the loadable resource transitioned to the LoadStatus.FAILED_TO_LOAD state, either due to calling loadAsync or retryLoadAsync.

        If the resource subsequently transitions to LoadStatus.LOADED, for example if a call to retryLoadAsync completes successfully, the error is cleared out.

        Specified by:
        getLoadError in interface Loadable
        Returns:
        the most recent error that was encountered when the loadable resource transitioned to the LoadStatus.FAILED_TO_LOAD state.
      • loadAsync

        public void loadAsync()
        Description copied from interface: Loadable
        Loads the metadata of the loadable resource asynchronously.

        The load status changes from LoadStatus.NOT_LOADED to LoadStatus.LOADING. A listener can be added via Loadable.addDoneLoadingListener(java.lang.Runnable) that is invoked upon completion of the asynchronous load operation.

        If the load operation completes successfully, the load status will be LoadStatus.LOADED, which means the resource has loaded its metadata.

        If the load operation failed, the load status will be LoadStatus.FAILED_TO_LOAD and the error can be retrieved by calling Loadable.getLoadError().

        This method can be called concurrently and repeatedly, but only one attempt is ever made to perform the load operation. If a load operation is already in progress (LoadStatus.LOADING state) when loadAsync is called, it simply piggy-backs on the outstanding operation and the done loading listener added to the loadable resource is enqueued to be invoked when that operation completes. If the operation has already completed (LoadStatus.LOADED or LoadStatus.FAILED_TO_LOAD state) when loadAsync is called, the done loading listener is immediately invoked when added to the loadable resource.

        If a loadable resource has failed to load, calling loadAsync on it subsequently will not change its state. The done loading listener will be invoked immediately when added to the loadable resource. In order to retry loading the resource, Loadable.retryLoadAsync() needs to be used.

        A load operation that is in progress (LoadStatus.LOADING state) can be cancelled by calling Loadable.cancelLoad().

        Specified by:
        loadAsync in interface Loadable
      • retryLoadAsync

        public void retryLoadAsync()
        Description copied from interface: Loadable
        Tries to reload the metadata of the loadable resource asynchronously, but only if the resource failed to load previously (LoadStatus.FAILED_TO_LOAD state) or wasn't loaded to begin with ( LoadStatus.NOT_LOADED state).

        For more details on the load process see Loadable.loadAsync().

        Specified by:
        retryLoadAsync in interface Loadable
      • cancelLoad

        public void cancelLoad()
        Description copied from interface: Loadable
        Cancels a pending load operation.

        A load operation that is in progress (LoadStatus.LOADING state) can be cancelled by calling this method and the resource will transition from LoadStatus.LOADING to LoadStatus.FAILED_TO_LOAD state. If the load operation was successfully cancelled a CancellationException will be returned from Loadable.getLoadError().

        Cancellation should be used carefully because all enqueued done loading listeners for that resource instance will get invoked with an error stating that the operation was cancelled. Thus, one component in the application can cancel the load operation initiated by other components.

        This method does nothing if the resource is not in LoadStatus.LOADING state.

        Specified by:
        cancelLoad in interface Loadable
      • addDoneLoadingListener

        public void addDoneLoadingListener​(Runnable listener)
        Description copied from interface: Loadable
        Adds a listener to the loadable resource that is invoked when loading has completed.

        The listener may be added at any point, whether the loadable resource has already completed loading or not.

        • For resources that are not loaded when the listener is added (LoadStatus is NOT_LOADED or LOADING): When the resource completes loading, the listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
        • For resources that are already loaded when the listener is added (LoadStatus is LOADED or FAILED_TO_LOAD): The listener will be called immediately, on the current thread.

        Alternatively, to be notified when there is any change in the load status, use the Loadable.addLoadStatusChangedListener(LoadStatusChangedListener) method instead.

        Specified by:
        addDoneLoadingListener in interface Loadable
        Parameters:
        listener - a Runnable that is invoked upon completion of the load operation
      • removeDoneLoadingListener

        public boolean removeDoneLoadingListener​(Runnable listener)
        Description copied from interface: Loadable
        Removes a done loading listener from the loadable resource.
        Specified by:
        removeDoneLoadingListener in interface Loadable
        Parameters:
        listener - the listener to be removed
        Returns:
        true if the listener was removed, otherwise false
      • addLoadStatusChangedListener

        public void addLoadStatusChangedListener​(LoadStatusChangedListener listener)
        Description copied from interface: Loadable
        Adds a LoadStatusChangedListener to the loadable resource that is invoked whenever the load status changes.

        Adding this listener on the UI thread will cause it to be invoked on the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.

        The listener will not be called if added to a loadable resource that has already completed loading. To be notified when a loadable resource has completed loading, including if the resource is already loaded when the listener is added, use the Loadable.addDoneLoadingListener(Runnable) method.

        Specified by:
        addLoadStatusChangedListener in interface Loadable
        Parameters:
        listener - the LoadStatusChangedListener to be added
      • removeLoadStatusChangedListener

        public boolean removeLoadStatusChangedListener​(LoadStatusChangedListener listener)
        Description copied from interface: Loadable
        Removes a LoadStatusChangedListener from the loadable resource.
        Specified by:
        removeLoadStatusChangedListener in interface Loadable
        Parameters:
        listener - the LoadStatusChangedListener to be removed
        Returns:
        true if the listener was removed, otherwise false