public abstract class

Layer

extends Object
java.lang.Object
   ↳ com.esri.android.map.Layer
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

The base layer for all layers that can be added into MapView.

Summary

Fields
protected UserCredentials credentials Gets the direct access of the credentials; You can access the credentials by the getCredentials() or setCredentials(UserCredentials); but those two methods copy the instance internally.
protected long nativeHandle
protected Map<Integer, ArcGISPopupInfo> popUpInfos
protected Object serviceInfo
Public Constructors
Layer()
Instantiates an object of Layer.
Protected Constructors
Layer(boolean initLayer)
Layer(long handle)
Instantiates an object of Layer.
Public Methods
Popup createPopup(MapView mapView, int sublayerId, Feature feature, PopupLayoutInfo layout, boolean useDefaultViews)
Creates a popup for a feature with the given layout.
Popup createPopup(MapView mapView, int sublayerId, Feature feature)
Creates a popup for a feature with the default layout.
UserCredentials getCredentials()
Gets a copy of the credentials attached to the Layer.
SpatialReference getDefaultSpatialReference()
Gets the defaultSpatialReference of the Layer.
Polygon getExtent()
Gets the current extent.
Envelope getFullExtent()
Returns the full extent of the layer.
int getHeight()
Gets the height of the Layer in screen units.
long getID()
Return the Layer runtime ID which is a long integer.
double getMaxScale()
Gets max scale.
double getMinScale()
Gets min scale.
String getName()
Gets the name of the layer.
float getOpacity()
Gets the opacity of the Layer.
Layer getParent()
Returns parent layer if the layer is in a group layer otherwise returning null.
ArcGISPopupInfo getPopupInfo(int sublayerId)
Gets the PopupInfo associated with the sub-layer id.
Map<Integer, ArcGISPopupInfo> getPopupInfos()
Gets the popup infos.
String getQueryUrl(int subLayerId)
Gets the query url.
double getResolution()
Gets the resolution of the Layer.
SpatialReference getSpatialReference()
Gets the current spatial reference of the Layer.
String getTitle()
Gets the title of the Layer.
String getUrl()
Gets the URL of the map service associated with the layer.
int getUrlHashCode()
A convenience method that returns the hash code of the map service URL.
String getWebMapLayerID()
Gets the web map layer id.
int getWidth()
Gets the width of the Layer in screen units.
boolean isInitialized()
Gets the initialized of the Layer.
boolean isRecycled()
Returns true or false if the Layer object has been recycled.
boolean isRenderNativeResolution()
Returns true if rendering at native resolution is enabled.
boolean isShowLegend()
Returns true if legend of the layer will be shown up; by default it is true; The property is usually defined in the web map, a operation layer legend could be on or off.
boolean isVisible()
Gets the visibility of the Layer.
boolean isWebMapBaselayer()
Returns true if the layer is used as base layer in a web map.
void recycle()
Releases resources referenced by the Layer so that they can be recycled.
void reinitializeLayer(UserCredentials usercredentials)
Re-initializes the layer with the given credentials.
void setMaxScale(double maxScale)
Sets max scale.
void setMinScale(double minScale)
Sets min scale.
void setName(String name)
Sets the layer name.
void setOnStatusChangedListener(OnStatusChangedListener onStatusChangedListener)
Sets the onStatusChangedListener.
void setOpacity(float opacity)
Sets the opacity of the Layer.
void setPopupInfos(Map<Integer, ArcGISPopupInfo> popUpInfos)
Sets the popup infos.
void setQueryUrls(Map<Integer, String> queryUrls)
Sets the query urls.
void setVisible(boolean visible)
Sets the visibility of the Layer.
Protected Methods
void changeStatus(OnStatusChangedListener.STATUS status)
Changes the STATUS of the layer and notifies the listener.
abstract long create()
void finalize()
float getDpi()
Envelope getInitialExtent()
Returns the initial extent of the layer.
ExecutorService getPoolExecutor()
Returns the ThreadPoolExecutor based on the context.
ExecutorService getServiceExecutor()
Returns the ThreadPoolExecutor based on the context.
abstract void initLayer()
Initializes the layer.
void initializeMinMaxScale(double initalMinScale, double initalMaxScale)
honor the webmaplayer min/max scale first, if it is not override, then using service min/max if they are set.
<T> T loadServiceInfo(Callable<T> task)
If the Layer is loaded as a WebMapLayer and the OnWebMapLoadListener is specified, the service information will be loaded interactively.
long lock()
void setCredentials(UserCredentials credentials)
Sets the credentials of the Layer.
void setDefaultSpatialReference(SpatialReference defaultSpatialReference)
Sets the defaultSpatialReference of the Layer.
void setFullExtent(Envelope extent)
void setInitialExtent(Envelope e)
Sets the initial extent of layer.
void setRenderNativeResolution(boolean renderNativeResolution)
Sets to true to use native resolution.
void setRenderPixelsPerInch(float pixelsPerInch)
void setUrl(String url)
Sets the URL of the map service associated with the layer.
void unlock(long handle)
void updateSpatialReferenceStatus(int SRStatus)
The callback method is invoked when the layer is added to map.
boolean verifyCredentials()
Returns true if the credentials is valid.
void waitForInitialized()
Waits for pending async initialization of the layer to finish.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

protected UserCredentials credentials

Gets the direct access of the credentials; You can access the credentials by the getCredentials() or setCredentials(UserCredentials); but those two methods copy the instance internally.

protected long nativeHandle

protected Map<Integer, ArcGISPopupInfo> popUpInfos

protected Object serviceInfo

Public Constructors

public Layer ()

Instantiates an object of Layer.

Protected Constructors

protected Layer (boolean initLayer)

Parameters
initLayer boolean

protected Layer (long handle)

Instantiates an object of Layer.

Parameters
handle long

Public Methods

public Popup createPopup (MapView mapView, int sublayerId, Feature feature, PopupLayoutInfo layout, boolean useDefaultViews)

Creates a popup for a feature with the given layout. Note: this is run from whatever thread it is called on, and may involve making a network request. Thus, this should not be called from the UI thread, or it may cause a NetworkOnUIThreadException.

Parameters
mapView MapView: the map view
sublayerId int: the sublayer id
feature Feature: the feature
layout PopupLayoutInfo: the popup layout configuration
useDefaultViews boolean: if true the default views will be created otherwise developers should create their own views.
Returns
Popup the popup

public Popup createPopup (MapView mapView, int sublayerId, Feature feature)

Creates a popup for a feature with the default layout. Note: this is run from whatever thread it is called on, and may involve making a network request. Thus, this should not be called from the UI thread, or it may cause a NetworkOnUIThreadException.

Parameters
mapView MapView: the map view
sublayerId int: the sublayer id
feature Feature: the feature
Returns
Popup the popup

public UserCredentials getCredentials ()

Gets a copy of the credentials attached to the Layer.

Returns
UserCredentials Returns the credentials.

public SpatialReference getDefaultSpatialReference ()

Gets the defaultSpatialReference of the Layer.

Returns
SpatialReference Returns the defaultSpatialReference.

public Polygon getExtent ()

Gets the current extent.

Returns
Polygon a polygon which represents the current extent.

public Envelope getFullExtent ()

Returns the full extent of the layer. Returns NULL if the layer does not have a full extent.

Returns
Envelope an Envelope object

public int getHeight ()

Gets the height of the Layer in screen units.

Returns
int height.

public long getID ()

Return the Layer runtime ID which is a long integer. A zero will be returned if the Layer object is invalid. Valid layer IDs are non-zero, i.e. can be negative or greater than zero.

Returns
long a long integer.

public double getMaxScale ()

Gets max scale. When map zooms in beyond max scale, graphics are not visible.

Returns
double max scale.

public double getMinScale ()

Gets min scale. When map zooms out beyond min scale, graphics are not visible.

Returns
double min scale

public String getName ()

Gets the name of the layer. The name is the name of the service if the layer is associated with a service, otherwise it is null. You should not call this method until the layer is initialized.

Returns
String the name of the associated service or null otherwise.

public float getOpacity ()

Gets the opacity of the Layer.

Returns
float the opacity.

public Layer getParent ()

Returns parent layer if the layer is in a group layer otherwise returning null.

Returns
Layer Layer a Layer object

public ArcGISPopupInfo getPopupInfo (int sublayerId)

Gets the PopupInfo associated with the sub-layer id.

Parameters
sublayerId int: the sublayer id
Returns
ArcGISPopupInfo PopupInfo

public Map<Integer, ArcGISPopupInfo> getPopupInfos ()

Gets the popup infos.

Returns
Map<Integer, ArcGISPopupInfo> the popup infos

public 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 double getResolution ()

Gets the resolution of the Layer.

Returns
double resolution.

public SpatialReference getSpatialReference ()

Gets the current spatial reference of the Layer.

Returns
SpatialReference spatial reference.

public String getTitle ()

Gets the title of the Layer. WebMap may define title of a layer, when the layer is instantiated from a WebMap, it may have a tile.

Returns
String Returns the title.

public String getUrl ()

Gets the URL of the map service associated with the layer.

Returns
String the URL as a string.

public int getUrlHashCode ()

A convenience method that returns the hash code of the map service URL. The hash codes for map service URLs are cached and this method spares the effort of the developer programmatically calculating the hash code.

Returns
int integer of the hashcode

public String getWebMapLayerID ()

Gets the web map layer id.

Returns
String the web map layer id

public int getWidth ()

Gets the width of the Layer in screen units.

Returns
int width.

public boolean isInitialized ()

Gets the initialized of the Layer.

Returns
boolean Returns the initialized.

public boolean isRecycled ()

Returns true or false if the Layer object has been recycled.

Returns
boolean boolean

public boolean isRenderNativeResolution ()

Returns true if rendering at native resolution is enabled.

Returns
boolean true, if rendering at native resolution is enabled.

public boolean isShowLegend ()

Returns true if legend of the layer will be shown up; by default it is true; The property is usually defined in the web map, a operation layer legend could be on or off.

Returns
boolean boolean

public boolean isVisible ()

Gets the visibility of the Layer.

Returns
boolean true if visible.

public boolean isWebMapBaselayer ()

Returns true if the layer is used as base layer in a web map.

Returns
boolean boolean

public void recycle ()

Releases resources referenced by the Layer so that they can be recycled.

public void reinitializeLayer (UserCredentials usercredentials)

Re-initializes the layer with the given credentials.

Parameters
usercredentials UserCredentials: the new credentials to try.

public void setMaxScale (double maxScale)

Sets max scale.

Parameters
maxScale double: max scale.

public void setMinScale (double minScale)

Sets min scale.

Parameters
minScale double: min scale.

public void setName (String name)

Sets the layer name.

Parameters
name String: a String

public void setOnStatusChangedListener (OnStatusChangedListener onStatusChangedListener)

Sets the onStatusChangedListener. When initialize a Layer, the OnStatusChangedListener notifies you the status changes for INITIALIZED or INITIALIZATION_FAILED. When the initialization is failed, you can use the getError() to get the error details.

Parameters
onStatusChangedListener OnStatusChangedListener: The onStatusChangedListener to set.

public void setOpacity (float opacity)

Sets the opacity of the Layer.

Parameters
opacity float: the opacity to set.

public void setPopupInfos (Map<Integer, ArcGISPopupInfo> popUpInfos)

Sets the popup infos.

Parameters
popUpInfos Map: the popup infos

public void setQueryUrls (Map<Integer, String> queryUrls)

Sets the query urls.

Parameters
queryUrls Map: the query urls

public void setVisible (boolean visible)

Sets the visibility of the Layer.

Parameters
visible boolean: The visibility to set.

Protected Methods

protected void changeStatus (OnStatusChangedListener.STATUS status)

Changes the STATUS of the layer and notifies the listener.

Parameters
status OnStatusChangedListener.STATUS: the new STATUS.

protected abstract long create ()

Returns
long

protected void finalize ()

Throws
Throwable

protected float getDpi ()

Returns
float

protected Envelope getInitialExtent ()

Returns the initial extent of the layer. Returns the full extent if the initial extent is not valid.

Returns
Envelope an Envelope object

protected ExecutorService getPoolExecutor ()

Returns the ThreadPoolExecutor based on the context.

Returns
ExecutorService

protected ExecutorService getServiceExecutor ()

Returns the ThreadPoolExecutor based on the context.

Returns
ExecutorService

protected abstract void initLayer ()

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

protected void initializeMinMaxScale (double initalMinScale, double initalMaxScale)

honor the webmaplayer min/max scale first, if it is not override, then using service min/max if they are set.

Parameters
initalMinScale double: - min scale of service.
initalMaxScale double: - max scale of service.

protected T loadServiceInfo (Callable<T> task)

If the Layer is loaded as a WebMapLayer and the OnWebMapLoadListener is specified, the service information will be loaded interactively.

Parameters
task Callable: the Task to load the service information.
Returns
T the service information.
Throws
Exception

protected long lock ()

Returns
long

protected void setCredentials (UserCredentials credentials)

Sets the credentials of the Layer. The layer holds the copy of the given instance.

Parameters
credentials UserCredentials: The credentials to set.

protected void setDefaultSpatialReference (SpatialReference defaultSpatialReference)

Sets the defaultSpatialReference of the Layer.

Parameters
defaultSpatialReference SpatialReference: The defaultSpatialReference to set.

protected void setFullExtent (Envelope extent)

Parameters
extent Envelope

protected void setInitialExtent (Envelope e)

Sets the initial extent of layer.

Parameters
e Envelope: --an Envelope object.

protected void setRenderNativeResolution (boolean renderNativeResolution)

Sets to true to use native resolution.

Parameters
renderNativeResolution boolean: true to enable rendering at native resolution.

protected void setRenderPixelsPerInch (float pixelsPerInch)

Parameters
pixelsPerInch float

protected void setUrl (String url)

Sets the URL of the map service associated with the layer.

Parameters
url String: the URL pointing to your map service.

protected void unlock (long handle)

Parameters
handle long

protected void updateSpatialReferenceStatus (int SRStatus)

The callback method is invoked when the layer is added to map. 0 - Spatial Reference Invalid 1 - Spatial Reference NotNeeded 2 - Spatial Reference Projected 3 - Spatial Reference Good, -1 -layer loading failed (security etc. reasons).

Parameters
SRStatus int: an integer indicating the spatial reference status of layer

protected boolean verifyCredentials ()

Returns true if the credentials is valid.

Returns
boolean

protected void waitForInitialized ()

Waits for pending async initialization of the layer to finish.

Throws
InterruptedException
ExecutionException
InterruptedException