- All Implemented Interfaces:
RemoteResource
,LayerContent
,Loadable
,PopupSource
ArcGISMapImageSublayer
provides access to layers that comprise an ArcGISMapImageLayer
. Once the
ArcGISMapImageLayer
has loaded, you can obtain its map image sublayers from the
ArcGISMapImageLayer.getSublayers()
collection. You can obtain the ArcGIS map service information for each
of these sublayers from the ArcGISSublayer.getMapServiceSublayerInfo()
.
If one of the sublayers is a group layer (where the ArcGISMapServiceSublayerInfo.getServiceType()
is
GROUP_LAYER
),
it will also have a collection of sublayers. Use ArcGISSublayer.getSublayers()
to obtain the collection of
sublayers. If one of these sublayers is a group layer it will also contain a collection of sublayers, and so on.
If you know the sublayer ID, you can create it from the ArcGISMapImageSublayer(int)
constructor.
Once you have obtained the sublayer, you can change the data that is displayed by the ArcGISMapImageLayer
by setting the sublayer's visibility, layer definition expression, and other visual properties such as
renderer and scale.
The code below shows how to get ArcGISMapImageSublayer
objects from an ArcGISMapImageLayer
and how
to change a property of a sublayer after loading.
String mapServiceUSA = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer"; final ArcGISMapImageLayer mapImageLayer = new ArcGISMapImageLayer(mapServiceUSA); mapImageLayer.addDoneLoadingListener(() -> { if (mapImageLayer.getLoadStatus() == LoadStatus.LOADED) { ListenableList<ArcGISSublayer> sublayerList = mapImageLayer.getSublayers(); ArcGISMapImageSublayer mapImageSublayer = (ArcGISMapImageSublayer) sublayerList.get(0); mapImageSublayer.setName("New Name"); } }); mapImageLayer.loadAsync();Setting properties on a ArcGISMapImageSublayer before the ArcGISMapImageLayer is loaded will not overwrite those properties.
- Since:
- 100.0.0
- See Also:
-
Property Summary
Properties inherited from class com.esri.arcgisruntime.layers.ArcGISSublayer
loadError, loadStatus
-
Constructor Summary
ConstructorDescriptionArcGISMapImageSublayer
(int id) Creates an ArcGIS map image sublayer with the specified sublayer ID.ArcGISMapImageSublayer
(int id, SublayerSource sublayerSource) Creates an ArcGIS map image sublayer with the specified sublayer ID and a source. -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Creates a deep copy of this ArcGISMapImageSublayer instance.Gets a modifiable collection of label definitions for this sublayer.Returns the sublayer's source if available.getTable()
Gets the sublayer's feature table.void
setDefinitionExpression
(String definitionExpression) The map image sublayer's definition expression.void
setLabelsEnabled
(boolean labelsEnabled) Sets whether labels are enabled for this sublayer.void
setMaxScale
(double maxScale) Sets the maximum scale at which the sublayer is visible.void
setMinScale
(double minScale) Sets the minimum scale at which the sublayer is visible.void
Sets the sublayer's name.void
setOpacity
(float opacity) Sets the sublayer's opacity.void
setRenderer
(Renderer renderer) Sets the sublayer's renderer.void
setScaleSymbols
(boolean scaleSymbols) Sets whether the sublayer renders its symbols based on scale.Methods inherited from class com.esri.arcgisruntime.layers.ArcGISSublayer
addDoneLoadingListener, addLoadStatusChangedListener, cancelLoad, canChangeVisibility, canScaleSymbols, canShowInLegend, copyTo, fetchLegendInfosAsync, getCredential, getDefinitionExpression, getId, getLoadError, getLoadStatus, getMapServiceSublayerInfo, getMaxScale, getMinScale, getName, getOpacity, getPopupDefinition, getRenderer, getRequestConfiguration, getSubLayerContents, getSublayers, getUri, isLabelsEnabled, isPopupEnabled, isVisible, isVisibleAtScale, loadAsync, loadErrorProperty, loadStatusProperty, removeDoneLoadingListener, removeLoadStatusChangedListener, retryLoadAsync, setCanShowInLegend, setCredential, setPopupDefinition, setPopupEnabled, setRequestConfiguration, setVisible
-
Constructor Details
-
ArcGISMapImageSublayer
public ArcGISMapImageSublayer(int id) Creates an ArcGIS map image sublayer with the specified sublayer ID.- Parameters:
id
- the ID of the new sub layer, should be zero or greater- Throws:
IllegalArgumentException
- if id is less than zero- Since:
- 100.0.0
-
ArcGISMapImageSublayer
Creates an ArcGIS map image sublayer with the specified sublayer ID and a source.Only map services that support dynamic layers will be able to manage sublayers with sublayer sources. The ArcGIS MapServer must have `Supports Dynamic Layers` equal to true in the ArcGIS REST Services Directory. For sublayer sources other than rasters, you must set an
ArcGISSublayer.getRenderer()
.- Parameters:
id
- the ID of the new sub layer, should be zero or greatersublayerSource
- the source of the new sublayer- Throws:
IllegalArgumentException
- if id is less than zeroIllegalArgumentException
- if sublayer source is null- Since:
- 100.1.0
-
-
Method Details
-
setRenderer
Sets the sublayer's renderer.- Overrides:
setRenderer
in classArcGISSublayer
- Parameters:
renderer
- the renderer to set- Throws:
IllegalArgumentException
- if the renderer is null- Since:
- 100.1.0
- See Also:
-
setOpacity
public void setOpacity(float opacity) Sets the sublayer's opacity.- 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- Throws:
IllegalArgumentException
- if the opacity is out of range- Since:
- 100.1.0
- See Also:
-
setScaleSymbols
public void setScaleSymbols(boolean scaleSymbols) Sets whether the sublayer renders its symbols based on scale.- Parameters:
scaleSymbols
- true if the text and symbols should change as the map scale varies, false otherwise- Since:
- 100.1.0
- See Also:
-
setMaxScale
public void setMaxScale(double maxScale) Sets the maximum scale at which the sublayer is visible.- Parameters:
maxScale
- the maximum scale- Since:
- 100.1.0
- See Also:
-
setMinScale
public void setMinScale(double minScale) Sets the minimum scale at which the sublayer is visible.- Parameters:
minScale
- the minimum scale- Since:
- 100.1.0
- See Also:
-
setLabelsEnabled
public void setLabelsEnabled(boolean labelsEnabled) Sets whether labels are enabled for this sublayer.- Parameters:
labelsEnabled
- true to enable labels, false otherwise- Since:
- 100.1.0
- See Also:
-
setDefinitionExpression
The map image sublayer's definition expression.The definition expression is a SQL statement where clause to filter out the features to be displayed. It uses the SQL-92 where clause syntax SQL-92. You must escape special characters in the expression string as required for your platform. The DATE keyword expects the date format yyyy-mm-dd and the TIMESTAMP keyword expects the time stamp format yyyy-mm-dd hh:mm:ss. For more information, see the ArcGIS Blog article Querying Feature Services Date-Time Queries.
Attempting to set the value to null will throw a NullPointerException exception.
- Parameters:
definitionExpression
- the definition expression- Since:
- 100.1.0
- See Also:
-
getSource
Returns the sublayer's source if available.- Returns:
- the sublayer's source
- Since:
- 100.1.0
-
setName
Sets the sublayer's name. This can be an empty string.- Parameters:
name
- the new name for this sublayer- Since:
- 100.0.0
-
copy
Creates a deep copy of this ArcGISMapImageSublayer instance.- Specified by:
copy
in classArcGISSublayer
- Returns:
- a deep copy of this ArcGISMapImageSublayer instance, which means that copies of all fields of this layer are made including its loading state
- Since:
- 100.1.0
-
getLabelDefinitions
Gets a modifiable collection of label definitions for this sublayer.This is only available if the
ArcGISMapImageLayer
supports dynamic capabilities.- Returns:
- a modifiable list of label definitions for this sublayer
- Since:
- 100.1.0
-
getTable
Gets the sublayer's feature table.This only applies to sublayers of type
ArcGISMapServiceSublayerInfo.ServiceType.FEATURE_LAYER
orArcGISMapServiceSublayerInfo.ServiceType.TABLE
. This method returns null if the sublayer has not been loaded.- Returns:
- the sublayer's feature table, or null if none
- Since:
- 100.3.0
-