public class

KmlLayer

extends Layer
implements TimeAwareLayer
java.lang.Object
   ↳ com.esri.android.map.Layer
     ↳ com.esri.android.map.ogc.kml.KmlLayer

Class Overview

The KmlLayer represents a layer based on a KML (Keyhole Markup Language) file (.kml,.kmz). KML is an XML tag based syntax that holds geographic information (geometric shapes, symbology, and attributes) in a file. KML uses a tag-based structure with nested elements and attributes and is based on the XML standard. For more information about KML and how to create a KML file, please refer to the google documentation.
A KmlLayer can be created by a local kml or kmz file on your device or a valid URL pointing to the files on the internet.

KML is typically composed of one or more KML features: a document, folder, placemark, network link or overlays. Each constituent feature is represented by a KmlNode object. The KmlNode of type Document( DOCUMENT) are the containers for features and styles and are referred to as RootNodes. A list of all the root nodes can be obtained by calling the getRootNodes() method.

NOTE: KML documents have the location measurements in WGS 84 (aka WGS 1984, EPSG:4326). When using a basemap with a coordinate system other than WGS 84, you need to wait for the KmlLayer to be loaded in order to get the reprojected coordinates.

 
 mapView.setOnStatusChangedListener(new OnStatusChangedListener() {

    public void onStatusChanged(Object source, STATUS status) {
       // TODO Auto-generated method stub
       if(source == kmlLayer && status == STATUS.LAYER_LOADED ){
       Log.d(TAG, "--- Source: mapView : kml layer loaded");
       ...
      }
    }
 });
 
 

See also:

Summary

Nested Classes
interface KmlLayer.KmlNodeEventListener Interface definition for a callback to be invoked when a node needs to refresh. 
[Expand]
Inherited Fields
From class com.esri.android.map.Layer
Public Constructors
KmlLayer(String kmlFile)
The constructor is used if you are instantiating a KMLLayer using a local file(kml/kmz) on the SDCard/internal storage or a publicly accessible URL
KmlLayer(String kmlFile, UserCredentials credential)
The constructor is used if you are instantiating a KMLLayer using a URL secured with username and password
Public Methods
void clearHighlightedNodes()
Clears all the highlighted and selected nodes
KmlNode[] getKmlNodes(double x, double y, int tolerance, boolean highlight)
Returns the KML nodes near the point specified by x,y coordinates in dip units.
KmlNode[] getKmlNodes(double x, double y, int tolerance)
Returns the KML nodes near the Point.
List<KmlNode> getRootNodes()
Returns a list of root nodes, i.e.
TimeExtent getTimeExtent()
Gets the valid TimeExtent object for the Layer or null if this KML does not support time based queries.
TimeInfo getTimeInfo()
Returns the TimeInfo of the layer.
TimeExtent getTimeInterval()
Get the current date/time range that this layer is filtered by.
boolean isTimeAware()
Indicates whether or not this KML layer instance is time aware.
void recycle()
(non-Javadoc)
void setKmlNodeEventListener(KmlLayer.KmlNodeEventListener kmlNodeEventListener)
Sets the KmlNode event listener.
void setSelectedNode(KmlNode node, boolean highlighted)
Sets the given KML node be selected.
void setSelectedNodes(KmlNode[] nodes, boolean highlighted)
Sets the given array of KML nodes be selected.
void setTimeInterval(TimeExtent timeExtent)
Sets the current date/time range that this layer will be filtered by.
Protected Methods
long create()
void initLayer()
Initializes the layer.
void updateSpatialReferenceStatus(int SRStatus, Object obj)
[Expand]
Inherited Methods
From class com.esri.android.map.Layer
From class java.lang.Object
From interface com.esri.core.map.TimeAwareLayer

Public Constructors

public KmlLayer (String kmlFile)

The constructor is used if you are instantiating a KMLLayer using a local file(kml/kmz) on the SDCard/internal storage or a publicly accessible URL

Parameters
kmlFile String: a local KML file path or a URL end point for a KML or KMZ file.

public KmlLayer (String kmlFile, UserCredentials credential)

The constructor is used if you are instantiating a KMLLayer using a URL secured with username and password

Parameters
kmlFile String: a local KML file path, or a URL end point for a KML or KMZ file.
credential UserCredentials: UserCredentials object.

Public Methods

public void clearHighlightedNodes ()

Clears all the highlighted and selected nodes

public KmlNode[] getKmlNodes (double x, double y, int tolerance, boolean highlight)

Returns the KML nodes near the point specified by x,y coordinates in dip units. The returned KML nodes get highlighted if true is passed for the highlight parameter.

Parameters
x double: screen x coordinate
y double: screen y coordinate
tolerance int: search tolerance in dip units (density-independent pixels)
highlight boolean: only works for placemarks, true to highlight returned placemarks.
Returns
KmlNode[] An array of KmlNode objects.

public KmlNode[] getKmlNodes (double x, double y, int tolerance)

Returns the KML nodes near the Point. The point is specified by the x,y in dip units

Parameters
x double: the x screen coordinate
y double: the y screen coordinate
tolerance int: search tolerance in dip units (density-independent pixels)
Returns
KmlNode[] An array of KmlNode objects.

public List<KmlNode> getRootNodes ()

Returns a list of root nodes, i.e. nodes of type DOCUMENT.

Returns
List<KmlNode> a list of root nodes.

public TimeExtent getTimeExtent ()

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

Returns
TimeExtent a TimeExtent object.

public TimeInfo getTimeInfo ()

Returns the TimeInfo of the layer.

Returns
TimeInfo TimeInfo object

public TimeExtent getTimeInterval ()

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

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

public boolean isTimeAware ()

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

Returns
boolean a boolean that indicates whether or not this KML layer instance is time aware

public void recycle ()

(non-Javadoc)

See also:

public void setKmlNodeEventListener (KmlLayer.KmlNodeEventListener kmlNodeEventListener)

Sets the KmlNode event listener.

public void setSelectedNode (KmlNode node, boolean highlighted)

Sets the given KML node be selected. The node will be highlighted if the highlighted parameter is true and the layer selection highlight is true.

Parameters
node KmlNode: KmlNode object
highlighted boolean: the node will be highlighted

public void setSelectedNodes (KmlNode[] nodes, boolean highlighted)

Sets the given array of KML nodes be selected. The nodes will be highlighted if the highlighted parameter is true and the layer selection highlight is true.

Parameters
nodes KmlNode: an array of KmlNode object.
highlighted boolean: boolean

public void setTimeInterval (TimeExtent timeExtent)

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

Parameters
timeExtent TimeExtent: the new date/time range

Protected Methods

protected long create ()

Returns
long

protected void initLayer ()

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

protected void updateSpatialReferenceStatus (int SRStatus, Object obj)

Parameters
SRStatus int
obj Object