Packagecom.afcomponents.umap.overlays
Classpublic class KMLLayer
InheritanceKMLLayer Inheritance Layer Inheritance MapObjectContainer Inheritance MapObject Inheritance flash.display.Sprite
SubclassesGeoRSSLayer, GPXLayer

KMLLayer is a special Layer that can create overlays from a KML source. This source can be an external file or an XML object. KML layer also supports automated loading of extenal KML files which are specified in <networkLink> tag.


Example
Here is a sample which creates new KML layer from external source:
 import com.afcomponents.umap.core.UMap;
 import com.afcomponents.umap.overlays.KMLLayer;
  
 // create map & attach it to stage
 var map:UMap = new UMap();
 map.setSize(300,300);
 addChild(map);
 
 // create new layer
 var kml:KMLLayer = new KMLLayer();
 kml.load("http://www.afcomponents.com/components/g_map/olympic_host_cities.kml");
 map.addOverlay(kml);



Public Properties
 PropertyDefined by
 InheritedasDisplayObject : DisplayObject
Returns reference to the object as a DisplayObject instance.
MapObject
 InheritedautoCloseInfo : Boolean
Gets or sets the autCloseInfo flag, which indicates whether to close info window automatically when user clicks somewhere on the map.
Layer
 InheritedautoInfo : Boolean
Gets or sets the autInfo flag, which indicates whether to open info window automatically upon mouse click.
Layer
  autoShow : Boolean
Gets or sets the autoShow property.
KMLLayer
 Inheritedcore : UMap
Returns reference to the core UMap object.
MapObject
 Inheriteddescription : String
Gets or sets the description text for the layer.
Layer
  expanded : Boolean
A flag which controls how this KML layer should be returned by toXML() method.
KMLLayer
 Inheritedid : uint
Gets or sets the ID of the object.
MapObject
 Inheritedinfo : IInfoWindow
Return referens to opened InfoWindow
Layer
 InheritedinfoParam : Object
Gets or sets the info window param object.
Layer
 InheritedinfoStyle : Object
Gets or sets the info window style object associated with the Overlay.
Layer
  keepXML : Boolean
Defines whether to keep XML in memory after downloading.
KMLLayer
  loader : URLLoader
[read-only] Returns a reference to the Loader object that is used for loading data from an external source.
KMLLayer
  loading : Boolean
[read-only] Returns true if data from external source is being loaded.
KMLLayer
  maxZoomLevel : Number
Gets or sets the maxZoomLevel property.
KMLLayer
 Inheritedname : String
Gets or sets the name of the object.
Layer
  networkLinks : uint
[read-only] Returns an array which holds references to the linked KMLLayers.
KMLLayer
 Inheritedowner : IMapObjectContainer
Returns reference to the owner container object.
MapObject
  source : String
[read-only] Returns URL of the layer's source data.
KMLLayer
  url : String
Defines the URL that should be exported via <networkLink> tag.
KMLLayer
 Inheritedvisible : Boolean
Gets or sets the Layer's visibility.
Layer
  xml : XML
[read-only] Returns a reference to the XML object with KML data.
KMLLayer
Public Methods
 MethodDefined by
  
KMLLayer(param:Object = null)
KML Layer constructor.
KMLLayer
 Inherited
addObject(object:IMapObject):void
Adds new IMapObject to the container.
MapObjectContainer
 Inherited
Adds new IOverlay to this Layer, invalidates and refreshes it.
Layer
 Inherited
bringForward(object:IMapObject):void
Moves the attached IMapObject forward in the display list.
MapObjectContainer
 Inherited
bringToFront(object:IMapObject):void
Brings the attached IMapObject to the top of the display list.
MapObjectContainer
  
cancel():void
Cancels the loading progress in this KMLLayer and all the linked KMLLayers.
KMLLayer
 Inherited
clearObjects(filter:Class = null):void
Removes all attached objects.
MapObjectContainer
 Inherited
Removes all attached overlays from the layer.
Layer
 Inherited
Creates an exact copy of this Layer with the attached Overlays and returns it to the user.
Layer
  
dispose():void
Releases all the resources accuired by the object.
KMLLayer
  
fromXML(xml:XML, param:Object = null, classObject:Class = null):KMLLayer
[static] Creates new KMLLayer from XML object in KML 2.2 format.
KMLLayer
 Inherited
Retruns Overlay bounds in geographical coordinates.
Layer
 Inherited
getBoundsXY(zoom:Number = 0):Bounds
Retruns Overlay bounds in bitmap coordinates.
Layer
 Inherited
getObject(id_or_name:*, filter:Class = null):IMapObject
Searches for an object with specified id or name.
MapObjectContainer
 Inherited
getObjectById(id:uint, filter:Class = null):IMapObject
Searches for an object with specified id.
MapObjectContainer
 Inherited
getObjectByName(name:String, matchCase:Boolean = false, filter:Class = null):IMapObject
Searches for an object with specified name.
MapObjectContainer
 Inherited
getObjects(filter:Class = null):Array
Returns an array of IMapObjects that where added to the container.
MapObjectContainer
 Inherited
getOverlay(id_or_name:*):IOverlay
Searches for an IOverlay object with specified id or name.
Layer
 Inherited
getOverlays():Array
Returns an array of IOverlay objects that where added to the Layer.
Layer
 Inherited
hide():void
Hides the Layer.
Layer
 Inherited
invalidate():void
Schedules the Layer for invalidation in 1 frame after this call.
Layer
 Inherited
isOwnerVisible():Boolean
Recursevly checks visibility of parent objects
MapObjectContainer
  
load(source:*):Boolean
Loads KML data from the specified source.
KMLLayer
 Inherited
redraw():void
Invalidates Overlays attached to the Layer.
Layer
 Inherited
refresh(full:Boolean = false):void
Refreshes the position of the Overlays attached to the Layer.
Layer
 Inherited
remove():void
Removes the object from the owner container object.
MapObject
 Inherited
removeObject(object:IMapObject):void
Removes IMapObject from the container.
MapObjectContainer
 Inherited
removeOverlay(overlay:IOverlay):void
Removes target IOverlay from the Layer.
Layer
 Inherited
sendBackward(object:IMapObject):void
Sends the attached IMapObject backward in the display list.
MapObjectContainer
 Inherited
sendToBack(object:IMapObject):void
Sends the attached IMapObject to the bottom of the display list.
MapObjectContainer
 Inherited
Adds the object to the specified IMapObjectContainer.
Layer
 Inherited
show():void
Shows the Layer.
Layer
 Inherited
toString():String
Returns a textual representation of the object.
MapObject
  
toXML(full:Boolean = true, afcTags:Boolean = false):XML
Builds an XML object in KML 2.1 format that describes the Overlay & it's style.
KMLLayer
 Inherited
updateMapType(mapType:IMapType):void
Invoked when map type has been changed.
Layer
 Inherited
updatePosition(latlng:LatLng):void
Invoked when the map position has been updated.
Layer
 Inherited
updateZoom(zoom:Number):void
Invoked when map the zoom has been updated.
Layer
Protected Methods
 MethodDefined by
  
createCircle(xml:XML):Circle
Creates Circle object specified by the xml data in KML 2.1 format.
KMLLayer
  
createMarker(xml:XML):Marker
Creates Marker object specified by the xml data in KML 2.1 format.
KMLLayer
  
Creates KMLLayer object specified by the xml data in KML 2.2 format.
KMLLayer
  
Creates Polygon object specified by the xml data in KML 2.1 format.
KMLLayer
  
Creates Polyline object specified by the xml data in KML 2.1 format.
KMLLayer
Events
 EventSummaryDefined by
   Dispatched when an KMLLayer has finished loading KML from an external source.KMLLayer
   Dispatched if a call to URLLoader.load() attempts to access data over HTTP and the current Flash Player environment is able to detect and return the status code for the request.KMLLayer
   Dispatched if a call to URLLoader.load() results in a fatal error that terminates the download.KMLLayer
   Dispatched when the download operation commences following a call to the URLLoader.load() method.KMLLayer
   Dispatched when KMLLayer enters ready state.KMLLayer
   Dispatched when data is received as the download operation progresses.KMLLayer
   Dispatched if a call to URLLoader.load() attempts to load data from a server outside the security sandbox.KMLLayer
Property detail
autoShowproperty
autoShow:Boolean  [read-write]

Gets or sets the autoShow property. Please note that this flag is ineffictive after Event.COMPLETE.

Implementation
    public function get autoShow():Boolean
    public function set autoShow(value:Boolean):void
expandedproperty 
expanded:Boolean  [read-write]

A flag which controls how this KML layer should be returned by toXML() method. If the expanded property is set to true, or source of the layer was set by XML data, then KML layer returned as a normal Layer with all it's contents. Otherwise only a NetworkLink is returned with the source URL.

The default value is <code>false</code>.

Implementation
    public function get expanded():Boolean
    public function set expanded(value:Boolean):void

See also

keepXMLproperty 
keepXML:Boolean  [read-write]

Defines whether to keep XML in memory after downloading.

The default value is <code>false</code>.

Implementation
    public function get keepXML():Boolean
    public function set keepXML(value:Boolean):void
loaderproperty 
loader:URLLoader  [read-only]

Returns a reference to the Loader object that is used for loading data from an external source.

Implementation
    public function get loader():URLLoader
loadingproperty 
loading:Boolean  [read-only]

Returns true if data from external source is being loaded.

Implementation
    public function get loading():Boolean
maxZoomLevelproperty 
maxZoomLevel:Number  [read-write]

Gets or sets the maxZoomLevel property. Please note that this flag is ineffictive after Event.COMPLETE.

Implementation
    public function get maxZoomLevel():Number
    public function set maxZoomLevel(value:Number):void
networkLinksproperty 
networkLinks:uint  [read-only]

Returns an array which holds references to the linked KMLLayers.

Implementation
    public function get networkLinks():uint
sourceproperty 
source:String  [read-only]

Returns URL of the layer's source data. If the layer has been loaded from XML object, returns "" (empty string).

Implementation
    public function get source():String
urlproperty 
url:String  [read-write]

Defines the URL that should be exported via <networkLink> tag. This property is also set when you call load(URI) method.

Implementation
    public function get url():String
    public function set url(value:String):void
xmlproperty 
xml:XML  [read-only]

Returns a reference to the XML object with KML data.

Implementation
    public function get xml():XML
Constructor detail
KMLLayer()constructor
public function KMLLayer(param:Object = null)

KML Layer constructor. If the source properties is specified in the param object, KML layer start loading right away. Otherwie use load(source) method to load KML data.

Here is a list of properties you can specify in the param object:

PropertyTypeDefaultDescription
autoShow Boolean true Defines whether to show layer content after loading.
maxZoomLevel Number 13 Defines the maximum zoom level for the auto show procedure.
source * A source with the KML data. See load() function for additional details.
expanded Boolean false Defines whether toXML() method should return full KML <Container> node, rather than a <NetworkLink> node.
keepXML Boolean false Defines whether to keep XML data in memory after it has been loaded. To access stored XML data, use xml property.

Parameters
param:Object (default = null) — Object that contains additional parameters for the KMLLayer.

See also

Method detail
cancel()method
public function cancel():void

Cancels the loading progress in this KMLLayer and all the linked KMLLayers.

createCircle()method 
protected function createCircle(xml:XML):Circle

Creates Circle object specified by the xml data in KML 2.1 format. Override this function to create custom Circles.

Parameters
xml:XML — XML data which describes the Circle.

Returns
Circle — Circle object.

See also

createMarker()method 
protected function createMarker(xml:XML):Marker

Creates Marker object specified by the xml data in KML 2.1 format. Override this function to create custom Markers.

Parameters
xml:XML — XML data which describes the Marker.

Returns
Marker — Marker object.

See also

createNetworkLink()method 
protected function createNetworkLink(xml:XML):KMLLayer

Creates KMLLayer object specified by the xml data in KML 2.2 format. Override this function to create custom KMLLayer.

Parameters
xml:XML — XML data which describes the external asset.

Returns
KMLLayer — KMLLayer object.

See also

createPolygon()method 
protected function createPolygon(xml:XML):Polygon

Creates Polygon object specified by the xml data in KML 2.1 format. Override this function to create custom Polygons.

Parameters
xml:XML — XML data which describes the Polygon.

Returns
Polygon — Polygon object.

See also

createPolyline()method 
protected function createPolyline(xml:XML):Polyline

Creates Polyline object specified by the xml data in KML 2.1 format. Override this function to create custom Polylines.

Parameters
xml:XML — XML data which describes the Polyline.

Returns
Polyline — Polyline object.

See also

dispose()method 
public override function dispose():void

Releases all the resources accuired by the object.

fromXML()method 
public static function fromXML(xml:XML, param:Object = null, classObject:Class = null):KMLLayer

Creates new KMLLayer from XML object in KML 2.2 format.

Parameters
xml:XML — XML object with root <NetworkLink> node which <Link> node with an URI to an external asset.
 
param:Object (default = null) — Default parameter Object that will be passed to the object's constructor.
 
classObject:Class (default = null) — Custom class object that will be instantiated instead of the default one.

Returns
KMLLayer — New KMLLayer object.

Example
Here is a sample KML structure:
  <NetworkLink id="ID">
    <!-- inherited from Feature element -->
    <name>...</name>                      <!-- string -->
    <visibility>1</visibility>            <!-- boolean -->
   
    <!-- specific to NetworkLink -->
    <Link>
      <href>...</href>                      <!-- string -->
    </Link>
  

load()method 
public function load(source:*):Boolean

Loads KML data from the specified source.

The source can be one of the following:

  • A String that specifies URL to an external KML file.
  • A URLRequest object that contains path to a KML file.
  • A XML object that contains data in KML format.
  • Parameters
    source:* — A source with KML data.

    Returns
    Boolean — A value of true if the source has been accepted; false if it was not.
    toXML()method 
    public override function toXML(full:Boolean = true, afcTags:Boolean = false):XML

    Builds an XML object in KML 2.1 format that describes the Overlay & it's style. Flag full indicates whether to build a complete KML data or just a container.

    Parameters
    full:Boolean (default = true) — A value of true if you want to return a full KML file with header; false if you want to get only a container with style and placemark nodes.
     
    afcTags:Boolean (default = false) — Flag that determines whether to generate KML data with extended AFC tags.

    Returns
    XML — XML object in KML 2.1 format.
    Event detail
    completeevent 
    Event object type: flash.events.Event

    Dispatched when an KMLLayer has finished loading KML from an external source.

    Defines the value of the type property of a complete event object.

    This event has the following properties:

    PropertyValue
    bubblesfalse
    cancelablefalse; there is no default behavior to cancel.
    currentTargetThe object that is actively processing the Event object with an event listener.
    targetThe network object that has completed loading.

    httpStatusevent  
    Event object type: flash.events.HTTPStatusEvent

    Dispatched if a call to URLLoader.load() attempts to access data over HTTP and the current Flash Player environment is able to detect and return the status code for the request. (Some browser environments may not be able to provide this information.) Note that the httpStatus event (if any) is sent before (and in addition to) any complete or error event.

    Defines the value of the type property of a httpStatus event object.

    This event has the following properties:

    PropertyValue
    bubblesfalse
    cancelablefalse; there is no default behavior to cancel.
    currentTargetThe object that is actively processing the Event object with an event listener.
    statusThe HTTP status code returned by the server.
    targetThe network object receiving an HTTP status code.

    ioErrorevent  
    Event object type: flash.events.IOErrorEvent

    Dispatched if a call to URLLoader.load() results in a fatal error that terminates the download.

    Defines the value of the type property of an ioError event object.

    This event has the following properties:

    PropertyValue
    bubblesfalse
    cancelablefalse; there is no default behavior to cancel.
    currentTargetThe object that is actively processing the Event object with an event listener.
    targetThe network object experiencing the input/output error.
    textText to be displayed as an error message.

    openevent  
    Event object type: flash.events.Event

    Dispatched when the download operation commences following a call to the URLLoader.load() method.

    Defines the value of the type property of an open event object.

    This event has the following properties:

    PropertyValue
    bubblesfalse
    cancelablefalse; there is no default behavior to cancel.
    currentTargetThe object that is actively processing the Event object with an event listener.
    targetThe network object that has opened a connection.

    overlayReadyevent  
    Event object type: com.afcomponents.umap.events.OverlayEvent
    OverlayEvent.type property = com.afcomponents.umap.events.OverlayEvent.READY

    Dispatched when KMLLayer enters ready state. This happens after all data from this Layer and all linked layers has been loaded.

    The OverlayEvent.READY constant defines the value of the type property of an overlayReady event object.

    This event has the following properties:

    PropertyValue
    bubblesfalse
    cancelablefalse; there is no default behavior to cancel.
    currentTarget The object that is actively processing the OverlayEvent object with an event listener.
    targetThe Overlay instance that has entered ready state.
    paramnull
    progressevent  
    Event object type: flash.events.ProgressEvent

    Dispatched when data is received as the download operation progresses.

    Defines the value of the type property of a progress event object.

    This event has the following properties:

    PropertyValue
    bubblesfalse
    bytesLoadedThe number of items or bytes loaded at the time the listener processes the event.
    bytesTotalThe total number of items or bytes that ultimately will be loaded if the loading process succeeds.
    cancelablefalse; there is no default behavior to cancel.
    currentTargetThe object that is actively processing the Event object with an event listener.
    targetThe network object reporting progress.

    securityErrorevent  
    Event object type: flash.events.SecurityErrorEvent

    Dispatched if a call to URLLoader.load() attempts to load data from a server outside the security sandbox.

    The SecurityErrorEvent.SECURITY_ERROR constant defines the value of the type property of a securityError event object.

    This event has the following properties:

    PropertyValue
    bubblesfalse
    cancelablefalse; there is no default behavior to cancel.
    currentTargetThe object that is actively processing the Event object with an event listener.
    targetThe network object reporting the security error.
    textText to be displayed as an error message.