public class

ArcGISDynamicMapServiceLayer

extends DynamicLayer
implements TimeAwareLayer
java.lang.Object
   ↳ com.esri.android.map.Layer
     ↳ com.esri.android.map.DynamicLayer
       ↳ com.esri.android.map.ags.ArcGISDynamicMapServiceLayer

Class Overview

The ArcGISDynamicMapServiceLayer class allows you to work with a dynamic map service resource that is exposed by the ArcGIS Server REST API (see the system requirements document for supported versions of ArcGIS Server). A dynamic map service generates map images on the server each time a request comes in.

The following are examples of how you might work with the ArcGISDynamicMapServiceLayer class. The code will add a map service from ArcGIS Online using map services that are dynamically retrieved. When working with dynamic services the ArcGISDynamicMapServiceLayer class must be used. This example code shows you how to connect to ArcGIS Online, but you can easily update the code to point to your own ArcGIS Server REST end points. Java usage:

 //ArcGISDynamicMapServiceLayer class is used to define the Layer that is added to the
 //MapView object.
 MapView mv = new MapView(this);
 mv.addLayer(new ArcGISDynamicMapServiceLayer(
 "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer"));
 setContentView(mv);
 

Summary

[Expand]
Inherited Fields
From class com.esri.android.map.DynamicLayer
From class com.esri.android.map.Layer
Public Constructors
ArcGISDynamicMapServiceLayer(String url, int[] visiblelayers)
This constructor is used when you're instantiating the ArcGISDynamicMapServiceLayer.
ArcGISDynamicMapServiceLayer(String url, int[] visiblelayers, UserCredentials credentials, boolean initLayer)
This constructor is used when you're instantiating the ArcGISDynamicMapServiceLayer.
ArcGISDynamicMapServiceLayer(String url, int[] visiblelayers, int[] invisibleLegendLayers, UserCredentials credentials, boolean initLayer)
This constructor is used when you're instantiating the ArcGISDynamicMapServiceLayer.
ArcGISDynamicMapServiceLayer(String url)
This constructor is used if you're instantiating the ArcGISDynamicMapServiceLayer (see the class description for an example of this usage).
ArcGISDynamicMapServiceLayer(String url, int[] visiblelayers, UserCredentials credentials)
This constructor is used if you're instantiating the ArcGISDynamicMapServiceLayer.
ArcGISDynamicMapServiceLayer(String url, int[] visiblelayers, Map<Integer, DrawingInfo> drawingOptions, UserCredentials credentials)
This constructor is used if you're instantiating the ArcGISDynamicMapServiceLayer.
Public Methods
List<DynamicLayerInfo> createDynamicLayerInfos()
Returns a list of default DynamicLayerInfo objects based on map service layers.
Future<ArcGISPopupInfo> createPopupInfo(int sublayerId, CallbackListener<ArcGISPopupInfo> callback)
Asynchronously creates a popup info.
ArcGISPopupInfo createPopupInfo(int sublayerId)
This method is deprecated. since 10.2.4, use createPopupInfo(int, CallbackListener) instead.
Future<LayerServiceInfo> fetchLayerServiceInfo(int sublayerId, CallbackListener<LayerServiceInfo> callback)
Asynchronously fetches the LayerServiceInfo for the specified sublayer.
Future<ArcGISPopupInfo> fetchPopupInfo(int sublayerId, CallbackListener<ArcGISPopupInfo> callback)
Asynchronously fetches the popup info.
ArcGISLayerInfo[] getAllLayers()
Returns all of sub-layers in a dynamic map service.
MapServiceCapabilities getCapabilities()
Gets the capabilities of the map service.
Map<Integer, DrawingInfo> getDrawingOptions()
Returns the current layers drawing options.
List<DynamicLayerInfo> getDynamicLayerInfos()
If this dynamic map service layer supports dynamic layer functionality, this method will return a list of DynamicLayerInfos that can be used to modify the drawing order and data source of each layer in the service.
Map<Integer, String> getLayerDefinitions()
Gets the layer definitions of the ArcGISDynamicMapServiceLayer.
LayerServiceInfo getLayerServiceInfo(int sublayerId)
Return the LayerServiceInfo for the specified sublayer.
ArcGISLayerInfo[] getLayers()
Returns the immediate sub-layers of the dynamic map service.
MapServiceInfo getMapServiceInfo()
ArcGISPopupInfo getPopupInfo(int sublayerId)
Gets the PopupInfo associated with the sub-layer id.
final String getQueryUrl(int subLayerId)
Gets the query url.
TimeExtent getTimeExtent()
Gets the valid TimeExtent object for the Layer or null if this service does not support time based queries.
TimeInfo getTimeInfo()
Get all the time awareness information for this layer.
TimeExtent getTimeInterval()
Get the current date/time range that this layer is filtered by.
Map<Integer, TimeOptions> getTimeOptions()
This method will return a list of.
boolean isDynamicLayersSupported()
Indicates whether or not this dynamic map service layer supports dynamic layer functionality; that is the ability to change a layer's renderer and data source.
boolean isTimeAware()
Indicates whether or not this particular layer instance is time aware.
boolean retrieveLegendInfo()
Supported on ArcGIS Server 10.01 and above.
void setDrawingOptions(Map<Integer, DrawingInfo> drawingInfos)
Specify a set of layer IDs with their DrawingInfos to override the way the layers are drawn.
void setDynamicLayerInfos(List<DynamicLayerInfo> dynamicLayerInfos)
Sets a list of DynamicLayerInfo instances that will be used to change the drawing order and data sources of sub-layers of this dynamic map service.
void setLayerDefinitions(Map<Integer, String> layerDefs)
Sets the layer definitions that are used to filter the features of individual layers in the map service.
void setTimeInterval(TimeExtent timeInterval)
Set the current date/time range that this layer will be filtered by.
void setTimeOptions(Map<Integer, TimeOptions> timeOptions)
Set a list of LayerTimeOptions.
Protected Methods
byte[] getImage(int width, int height, Envelope extent)
void initLayer()
Initializes the layer.
[Expand]
Inherited Methods
From class com.esri.android.map.DynamicLayer
From class com.esri.android.map.Layer
From class java.lang.Object
From interface com.esri.android.map.popup.PopupLayer
From interface com.esri.core.map.TimeAwareLayer

Public Constructors

public ArcGISDynamicMapServiceLayer (String url, int[] visiblelayers)

This constructor is used when you're instantiating the ArcGISDynamicMapServiceLayer.

Parameters
url String: the URL of the dynamic map service.
visiblelayers int: the IDs of the layers that are visible. Set to null if all layers are visible.

public ArcGISDynamicMapServiceLayer (String url, int[] visiblelayers, UserCredentials credentials, boolean initLayer)

This constructor is used when you're instantiating the ArcGISDynamicMapServiceLayer.

Parameters
url String: the URL of the dynamic map service.
visiblelayers int: the IDs of the layers that are visible. Set to null if all layers are visible.
credentials UserCredentials: the credentials used for accessing a secure dynamic map service
initLayer boolean: set to true to initialize the layer.

public ArcGISDynamicMapServiceLayer (String url, int[] visiblelayers, int[] invisibleLegendLayers, UserCredentials credentials, boolean initLayer)

This constructor is used when you're instantiating the ArcGISDynamicMapServiceLayer.

Parameters
url String: the URL of the dynamic map service.
visiblelayers int: the IDs of the layers that are visible. Set to null if all layers are visible.
invisibleLegendLayers int: the IDs of the layers whose legends are invisible. Set to null if all layers legend are visible.
credentials UserCredentials: the credentials used for accessing a secure dynamic map service
initLayer boolean: set to true to initialize the layer.

public ArcGISDynamicMapServiceLayer (String url)

This constructor is used if you're instantiating the ArcGISDynamicMapServiceLayer (see the class description for an example of this usage).

Parameters
url String: the URL of the dynamic map service.

public ArcGISDynamicMapServiceLayer (String url, int[] visiblelayers, UserCredentials credentials)

This constructor is used if you're instantiating the ArcGISDynamicMapServiceLayer.

Parameters
url String: the URL of the dynamic map service.
visiblelayers int: the IDs of the layers are visible. Set to null if all layers are visible.
credentials UserCredentials: the credentials used for accessing a secure dynamic map service

public ArcGISDynamicMapServiceLayer (String url, int[] visiblelayers, Map<Integer, DrawingInfo> drawingOptions, UserCredentials credentials)

This constructor is used if you're instantiating the ArcGISDynamicMapServiceLayer.

Parameters
url String: the URL of the dynamic map service.
visiblelayers int: the IDs of the layers are visible. Set to null if all layers are visible.
drawingOptions Map: options for setting layer rendering.
credentials UserCredentials: the credentials used for accessing a secure dynamic map service

Public Methods

public List<DynamicLayerInfo> createDynamicLayerInfos ()

Returns a list of default DynamicLayerInfo objects based on map service layers. Only visible layers are in the returning list.

Returns
List<DynamicLayerInfo> a list of DynamicLayerInfo objects.

public Future<ArcGISPopupInfo> createPopupInfo (int sublayerId, CallbackListener<ArcGISPopupInfo> callback)

Asynchronously creates a popup info. If the popup info already exists and its information is fully populated, then it will simply be returned. If it exists but is missing some information, then a network request will be made to fetch the missing information. If the popup info does not exist, it will be created and then a network request will be made to fetch its full information.

Parameters
sublayerId int: the id of the sublayer for which the popup info should be created
callback CallbackListener: the callback to notify upon completion of creating the popup info
Returns
Future<ArcGISPopupInfo> a Future containing the created popup info.

public ArcGISPopupInfo createPopupInfo (int sublayerId)

This method is deprecated.
since 10.2.4, use createPopupInfo(int, CallbackListener) instead.

Creates the popup info.

Parameters
sublayerId int: the sublayer id
Returns
ArcGISPopupInfo the ArcGISPopupInfo

public Future<LayerServiceInfo> fetchLayerServiceInfo (int sublayerId, CallbackListener<LayerServiceInfo> callback)

Asynchronously fetches the LayerServiceInfo for the specified sublayer. If the LayerServiceInfo has already been fetched, then it will simply return that. Otherwise a network request will be made to fetch it. Once it has been fetched, it will be cached so that getLayerServiceInfo(int) will return it, and so that it won't be fetched more than once.

Parameters
sublayerId int: the id of the sublayer for which to get the LayerServiceInfo
callback CallbackListener: the callback to call once the LayerServiceInfo has been retrieved.
Returns
Future<LayerServiceInfo> a Future containing the LayerServiceInfo info for the specified sublayer

public Future<ArcGISPopupInfo> fetchPopupInfo (int sublayerId, CallbackListener<ArcGISPopupInfo> callback)

Asynchronously fetches the popup info. If the popup info exists and its information is fully populated, then it will simply be returned. If it exists but is missing some information, then a network request will be made to fetch the missing information. If the popup info does not exist, then null will be returned

Parameters
sublayerId int: The id of the sublayer for which the popup info should be returned
callback CallbackListener: The callback to notify upon completion of fetching the popup info's full information
Returns
Future<ArcGISPopupInfo> A Future containing the popup info with the fetched full information, or null if there was no popup info.

public ArcGISLayerInfo[] getAllLayers ()

Returns all of sub-layers in a dynamic map service. See getLayers() if you need the layer returned in hierarchy.

Returns
ArcGISLayerInfo[] an array of type ArcGISLayerInfo.

public MapServiceCapabilities getCapabilities ()

Gets the capabilities of the map service. It is an object containing boolean checks against supported operations (e.g. Map, Query, Data). Only available if the map service is published using ArcGIS Server version 10 or greater. You can not call this method until the layer is loaded.

Returns
MapServiceCapabilities the map service capabilities or null if the associated server doesn't support it.

public Map<Integer, DrawingInfo> getDrawingOptions ()

Returns the current layers drawing options.

Returns
Map<Integer, DrawingInfo> a HashMap object containing the layer id as key, and its corresponding DrawingInfo objects.

public List<DynamicLayerInfo> getDynamicLayerInfos ()

If this dynamic map service layer supports dynamic layer functionality, this method will return a list of DynamicLayerInfos that can be used to modify the drawing order and data source of each layer in the service. If this property has not been previously set by the user, an default list may be returned.

Returns
List<DynamicLayerInfo> a list of DynamicLayerInfo instances if dynamic layer functionality is supported, null or empty list otherwise.

public Map<Integer, String> getLayerDefinitions ()

Gets the layer definitions of the ArcGISDynamicMapServiceLayer.

Returns
Map<Integer, String> Returns the layerDefs.

public LayerServiceInfo getLayerServiceInfo (int sublayerId)

Return the LayerServiceInfo for the specified sublayer. If the the LayerServiceInfo has not yet been fetched for that sublayer, then null will be returned. To fetch the LayerServiceInfo, see fetchLayerServiceInfo(int, CallbackListener).

Parameters
sublayerId int: the id of the sublayer for which to get the LayerServiceInfo
Returns
LayerServiceInfo the LayerServiceInfo for the specified sublayer

public ArcGISLayerInfo[] getLayers ()

Returns the immediate sub-layers of the dynamic map service. If a layer is a group layer, you can call the getLayers() method to get the sub-layer of the group layer.

Returns
ArcGISLayerInfo[] an array of type ArcGISLayerInfo.

public MapServiceInfo getMapServiceInfo ()

Returns
MapServiceInfo

public ArcGISPopupInfo getPopupInfo (int sublayerId)

Gets the PopupInfo associated with the sub-layer id.

Parameters
sublayerId int: the sublayer id
Returns
ArcGISPopupInfo PopupInfo

public final String getQueryUrl (int subLayerId)

Gets the query url.

Parameters
subLayerId int: the sub layer id
Returns
String the queryUrl for the sub-layer ID.

public TimeExtent getTimeExtent ()

Gets the valid TimeExtent object for the Layer or null if this service does not support time based queries.

Returns
TimeExtent the valid range of dates for this layer.

public TimeInfo getTimeInfo ()

Get all the time awareness information for this layer.

Returns
TimeInfo the time awareness information as a TimeInfo object

public TimeExtent getTimeInterval ()

Get the current date/time range that this layer is filtered by.

Returns
TimeExtent the current date/time range

public Map<Integer, TimeOptions> getTimeOptions ()

This method will return a list of.

Returns
Map<Integer, TimeOptions> list of LayerTimeOptions instances that can be used to indicate whether or not each layer should use the time extent specified by the TimeInterval property or not, whether to draw the layer features cumulatively or not and the time offsets for the layer. If this property has not been previously set by the user, the returned Map will be empty.

public boolean isDynamicLayersSupported ()

Indicates whether or not this dynamic map service layer supports dynamic layer functionality; that is the ability to change a layer's renderer and data source.

Returns
boolean true if dynamic layer functionality is supported

public boolean isTimeAware ()

Indicates whether or not this particular layer instance is time aware.

Returns
boolean True if this is a time aware layer, false otherwise.

public boolean retrieveLegendInfo ()

Supported on ArcGIS Server 10.01 and above.
Synchronously retrieves the legend information for all the layers and populate each layers legend info into its Layer info. Once finished, getLegend() may be called on the individual ArcGISLayerInfos that make up this ArcGISDynamicMapServiceLayer.

Note: The developer is responsible for calling this method in a non-UI thread.

Returns
boolean boolean

public void setDrawingOptions (Map<Integer, DrawingInfo> drawingInfos)

Specify a set of layer IDs with their DrawingInfos to override the way the layers are drawn. The layers must be current visible, and exist in current DynamicLayerInfo list.

Parameters
drawingInfos Map: a set of layerIDs of the layers to be drawn with their new DrawingInfo.

public void setDynamicLayerInfos (List<DynamicLayerInfo> dynamicLayerInfos)

Sets a list of DynamicLayerInfo instances that will be used to change the drawing order and data sources of sub-layers of this dynamic map service. Note that this property only works if the dynamic layers supported (ArcGIS Server 10.1 or later).

Parameters
dynamicLayerInfos List: a list of DynamicLayerInfo instances. The layers will be rendered in the dynamic map service in the same order as the entries in this list with the first item at the top and the last item at the bottom. Items in this list will reflect the current sub-layer visibility settings; any layer marked as invisible will not render. Any layer marked as visible that doesn't have a corresponding DynamicLayerInfo instance will be drawn below the other layers using the service default renderer and data source.

public void setLayerDefinitions (Map<Integer, String> layerDefs)

Sets the layer definitions that are used to filter the features of individual layers in the map service.

Java sample:

 layer = new ArcGISDynamicMapServiceLayer("http://yourhost/MapServer");
 HashMap<Integer, String> layerDefs = new HashMap<Integer, String>();
 layerDefs.put(Integer.valueOf(1), "pop1990 > 5000000");
 layer.setLayerDefinitions(layerDefs);
 
 map.addLayer(layer);
 

Parameters
layerDefs Map: The layerDefs to set. The key is the index of the sublayer, the value is the where clause.

public void setTimeInterval (TimeExtent timeInterval)

Set the current date/time range that this layer will be filtered by.

Parameters
timeInterval TimeExtent: the new date/time range

public void setTimeOptions (Map<Integer, TimeOptions> timeOptions)

Set a list of LayerTimeOptions.

Parameters
timeOptions Map: list of LayerTimeOptions to apply to this layer

Protected Methods

protected byte[] getImage (int width, int height, Envelope extent)

Parameters
width int
height int
extent Envelope
Returns
byte[]
Throws
Exception

protected void initLayer ()

Initializes the layer. The implementation should submit the OnStatusChangedListener.STATUS event accordingly.