com.esri.map
Class KMLLayer

java.lang.Object
  extended by com.esri.map.Layer
      extended by com.esri.map.GroupLayer
          extended by com.esri.map.KMLLayer

public class KMLLayer
extends GroupLayer

The KMLLayer class represents a layer based on a KML file (.kml,.kmz). KML is an XML tag based syntax that holds geographic information (geometric shapes, symbology, and attributes) in a file with the .kml extension. To add a KML file(.kml or .kmz) to a map, the KML must be available via a publicly accessible URL. Locally hosted or KML files inside a firewall are not supported. KML Layer is a group layer which is made up of several layers in order to support wide range of feature types that can be stored in a KML file. Geometries from a KML file are stored as feature layers: one each for points, lines and polygons. The feature layer can be accessed by iterating the children of the GroupLayer.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.esri.map.Layer
Layer.LayerStatus
 
Field Summary
protected  List<Layer> innerLayers
           
 
Fields inherited from class com.esri.map.Layer
_credentials, _progress, _resolutionList, serviceInfo
 
Constructor Summary
KMLLayer(String url)
          The constructor is used if you are instantiating a KMLLayer using a publicly accessible URL.
KMLLayer(String url, SpatialReference outSR)
          The constructor is used if you are instantiating a KMLLayer using a URL and output spatial reference.
 
Method Summary
 boolean contains(Layer layer)
           
protected  void createNativeLayer()
           
protected  boolean doesExist(com.esri.map.GroupLayerBase grouplayer, Layer checklayer)
           
protected  void finalize()
           
 Layer get(int index)
          Returns the layer for the given index position.
 SpatialReference getDefaultSpatialReference()
          Gets the defaultSpatialReference of the Layer.
 Envelope getFullExtent()
          Returns the full extent of the layer.
 long getID()
          Return the Layer runtime ID which is a long integer.
 Layer getLayer(String layername)
          Returns the layer for the given layer name.
 Layer[] getLayers()
          Returns the direct sublayers in an array.
 LayerLegendInfoCollection getLegend()
           
 double getMaxScale()
          Gets the maximum scale at which this layer will be displayed.
 double getMinScale()
          Gets the minimum scale at which this layer will be displayed.
protected  void graphicsLayerAddRequest(String layerName, int index)
           
protected  void init(boolean isVisible, int[] visibleLayers, String title, float opacity)
          This method is called only when composing a Map from a Web Map.
protected  void initializeNativeLayer()
           
protected  int internalAdd(Layer layer)
           
protected  boolean internalAddLayerAt(Layer layer, int index)
           
protected  void internalInit()
           
 boolean isEmpty()
           
 boolean isInitialized()
           
 void recycle()
          Releases resources referenced by the Layer so that they can be recycled.
protected  void recycleLayers()
           
 void refresh()
          Refreshes the KML layer by downloading and parsing the KML document.
protected  void setDefaultSpatialReference(SpatialReference defaultSpatialReference)
          Sets the defaultSpatialReference of the Layer.
protected  void setMap(JMap parent)
          Every layer is provided a reference to the parent JComponent that contains that layer.
 void setOpacity(float opacity)
          Sets the opacity of the GroupLayer, it will change all opacity of it sublayers.
 void setVisible(boolean visible)
          Sets the visibility of the Layer.
 int size()
          Returns the size of the group layer.
protected  void updateSpatialReferenceStatus(int SRStatus)
           
 
Methods inherited from class com.esri.map.GroupLayer
add, addAll, addLayerAt, clear, remove, remove
 
Methods inherited from class com.esri.map.Layer
addLayerInitializeCompleteListener, fireLayerCreateCompleteEvent, fireLayerCreateErrorEvent, fireLayerCreateErrorEvent, getCopyrightText, getCredentialsInternal, getDescription, getException, getExtent, getInitialExtent, getInitializationError, getLayerHandle, getMap, getMapServer, getMapServerInfo, getMapServerLegendInfo, getName, getOpacity, getPopupInfo, getResolution, getResolutionList, getServiceDescription, getSpatialReference, getStatus, getUrl, getUrlHashCode, initializeAsync, internalGetLayerLegendInfos, isHidingNoDataTiles, isReady, isShowingCopyright, isVisible, loadServiceInfo, lock, reinitializeAsync, removeLayerInitializeCompleteListener, setCopyrightText, setCredentials, setDescription, setError, setException, setFullExtent, setInitialExtent, setLayerHandle, setMapServer, setName, setPopupInfos, setServiceDescription, setShowingCopyright, setStatus, setUrl, unlock
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

innerLayers

protected final List<Layer> innerLayers
Constructor Detail

KMLLayer

public KMLLayer(String url)
The constructor is used if you are instantiating a KMLLayer using a publicly accessible URL. The default output spatial reference is WGS84.

Parameters:
url - string URL to the KML file.

KMLLayer

public KMLLayer(String url,
                SpatialReference outSR)
The constructor is used if you are instantiating a KMLLayer using a URL and output spatial reference.

Parameters:
url - string URL to the KML file.
outSR - output spatial reference.
Method Detail

updateSpatialReferenceStatus

protected void updateSpatialReferenceStatus(int SRStatus)
Overrides:
updateSpatialReferenceStatus in class Layer

refresh

public void refresh()
Refreshes the KML layer by downloading and parsing the KML document.


internalInit

protected void internalInit()

isInitialized

public boolean isInitialized()
Overrides:
isInitialized in class Layer

setVisible

public void setVisible(boolean visible)
Description copied from class: Layer
Sets the visibility of the Layer.

Overrides:
setVisible in class Layer
Parameters:
visible - The visibility to set.

recycle

public void recycle()
Description copied from class: Layer
Releases resources referenced by the Layer so that they can be recycled.


getLayers

public Layer[] getLayers()
Returns the direct sublayers in an array.

Returns:
an array of Layer objects

getLayer

public Layer getLayer(String layername)
Returns the layer for the given layer name.

Parameters:
layername - a layer name string
Returns:
a Layer object

get

public Layer get(int index)
Returns the layer for the given index position.

Parameters:
index - an integer for layer position.
Returns:
a Layer object

isEmpty

public boolean isEmpty()

contains

public boolean contains(Layer layer)

size

public int size()
Returns the size of the group layer.

Returns:
the size of the group layer.

setOpacity

public void setOpacity(float opacity)
Sets the opacity of the GroupLayer, it will change all opacity of it sublayers.

Overrides:
setOpacity in class Layer
Parameters:
opacity - the opacity to set.

getFullExtent

public Envelope getFullExtent()
Returns the full extent of the layer. Returns NULL if the group layer is empty.

Overrides:
getFullExtent in class Layer
Returns:
an Envelope object

getDefaultSpatialReference

public SpatialReference getDefaultSpatialReference()
Gets the defaultSpatialReference of the Layer.

Overrides:
getDefaultSpatialReference in class Layer
Returns:
Returns the defaultSpatialReference.

getID

public long getID()
Return the Layer runtime ID which is a long integer. A zero will be returned if the Layer object is invalid.

Returns:
a long integer.

getMinScale

public double getMinScale()
Description copied from class: Layer
Gets the minimum scale at which this layer will be displayed. For service layers this is defined by the service. For a GraphicsLayer there is no minimum scale.

Overrides:
getMinScale in class Layer
Returns:
the minimum scale

getMaxScale

public double getMaxScale()
Description copied from class: Layer
Gets the maximum scale at which this layer will be displayed. For service layers this is defined by the service. For a GraphicsLayer there is no maximum scale.

Overrides:
getMaxScale in class Layer
Returns:
the maximum scale

getLegend

public LayerLegendInfoCollection getLegend()
Specified by:
getLegend in class Layer

setDefaultSpatialReference

protected void setDefaultSpatialReference(SpatialReference defaultSpatialReference)
Sets the defaultSpatialReference of the Layer.

Overrides:
setDefaultSpatialReference in class Layer
Parameters:
defaultSpatialReference - The defaultSpatialReference to set.

internalAdd

protected int internalAdd(Layer layer)
Parameters:
layer -
Returns:

internalAddLayerAt

protected boolean internalAddLayerAt(Layer layer,
                                     int index)
Parameters:
layer -
index -
Returns:

doesExist

protected boolean doesExist(com.esri.map.GroupLayerBase grouplayer,
                            Layer checklayer)

recycleLayers

protected void recycleLayers()

graphicsLayerAddRequest

protected void graphicsLayerAddRequest(String layerName,
                                       int index)

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Layer
Throws:
Throwable

init

protected void init(boolean isVisible,
                    int[] visibleLayers,
                    String title,
                    float opacity)
Description copied from class: Layer
This method is called only when composing a Map from a Web Map. The web map contains properties that every layer should be initialized with, up front.

Specified by:
init in class Layer

createNativeLayer

protected void createNativeLayer()
Specified by:
createNativeLayer in class Layer

initializeNativeLayer

protected void initializeNativeLayer()
Specified by:
initializeNativeLayer in class Layer

setMap

protected void setMap(JMap parent)
Description copied from class: Layer
Every layer is provided a reference to the parent JComponent that contains that layer. Layers can use the existence or absence of a parent to determine if are being used in a JMap.

Overrides:
setMap in class Layer
Parameters:
parent - the new parent component


Copyright © 2012. All Rights Reserved.