Packagecom.afcomponents.umap.overlays
Classpublic class Marker
InheritanceMarker Inheritance Overlay Inheritance MapObject Inheritance flash.display.Sprite

Marker is an overlay used for indicating positions on the map. Marker appearence is defined by a MarkerStyle object.


Example
Here is an example of creating random markers on the map:
 import com.afcomponents.umap.core.UMap;
 import com.afcomponents.umap.styles.MarkerStyle;
 import com.afcomponents.umap.styles.GeometryStyle;
 import com.afcomponents.umap.overlays.Marker;
 import com.afcomponents.umap.types.LatLng;
 import com.afcomponents.umap.types.LatLngBounds;
  
 // create new UMap object
 var map:UMap = new UMap();
 map.setSize(300, 300);
 this.addChild(map);
  
 // create new MarkerStyle
 var style:MarkerStyle = new MarkerStyle();
 style.fill = GeometryStyle.RGB;
 style.fillAlpha = 0.9;
 style.strokeRGB = 0x0;
 style.strokeAlpha = 1.0;
  
 var pos:LatLng;
 var bounds:LatLngBounds = map.getBoundsLatLng();
 var marker:Marker;
  
 // create 25 random Markers
 for (var i:uint = 0; i < 25; i++)
 {
  style.fillRGB = Math.random() * 0xFFFFFF;
  pos = new LatLng(bounds.southWest.lat + Math.random() * bounds.height, bounds.southWest.lng + Math.random() * bounds.width);
  marker = new Marker();
  marker.index = String.fromCharCode(65 + i);
  marker.position = pos;
  marker.setStyle(style);
  map.addOverlay(marker);
 }
 

Here is what you should see after executing the code:

Marker example

See also

com.afcomponents.umap.styles.MarkerStyle


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.
Overlay
 InheritedautoInfo : Boolean
Gets or sets the autInfo flag, which indicates whether to open info window automatically upon mouse click.
Overlay
 Inheritedcore : UMap
Returns reference to the core UMap object.
MapObject
 Inheriteddata : *
Gets or sets the data parameter of the Overlay.
Overlay
 Inheriteddescription : String
Gets or sets the description text of the Overlay.
Overlay
 Inheriteddraggable : Boolean
Gets or sets Overlay's draggable property.
Overlay
 Inheriteddragging : Boolean
Indicates whether Overlay is being dragged at the moment.
Overlay
  enabled : Boolean
Marker
  icon : DisplayObject
[read-only] Returns a reference to a custom icon object.
Marker
  iconLoader : Loader
[read-only] Returns a reference to a Loader object used by this Marker for loading external icons.
Marker
 Inheritedid : uint
Gets or sets the ID of the object.
MapObject
  index : String
Gets or sets the index property of the Marker.
Marker
 Inheritedinfo : IInfoWindow
Return referens to opened InfoWindow
Overlay
 InheritedinfoParam : Object
Gets or sets the info window param object.
Overlay
 InheritedinfoStyle : Object
Gets or sets the info window style object associated with the Overlay.
Overlay
 Inheritedname : String
Gets or sets the name of the object.
Overlay
 Inheritedowner : IMapObjectContainer
Returns reference to the owner container object.
MapObject
 Inheritedpoint : Point
Returns the position of the Overlay in bitmap coordinates.
Overlay
 Inheritedposition : LatLng
Gets or set the geographical position of the Overlay.
Overlay
 InheritedsmartPosition : Boolean
Gets or sets the smartPosition flag, which indicates whether to use smart positioning with the Overlay.
Overlay
 InheritedsmartPositionOffset : Number
Overlay
 Inheritedvisible : Boolean
Gets or sets the Overlay's visibility.
Overlay
 InheritedzIndexAuto : Boolean
Gets or sets zIndexAuto property which indicates wheter Overlay should be brought to front on mouse over event.
Overlay
Public Methods
 MethodDefined by
  
Marker(param:Object = null, style:Object = null)
Marker constructor.
Marker
 Inherited
addEventListeners(target:InteractiveObject = null):void
Adds a built-in listener for MouseEvents fired by an InteractiveObject contained in the Overlay.
Overlay
 Inherited
bringToFront():void
Brings target Overlay to the top of the parent's display list.
Overlay
  
Creates an exact copy of this Overlay and returns it to the user.
Marker
 Inherited
Closes info window that is currently opened.
Overlay
  
dispose():void
Releases all the resources accuired by the object.
Marker
 Inherited
dragStart():void
Starts Overlay dragging.
Overlay
 Inherited
dragStop():void
Stops Overlay dragging.
Overlay
  
fromXML(xml:XML, param:Object = null, style:Object = null, classObject:Class = null):Marker
[static] Creates new Marker from XML object in KML 2.1 format.
Marker
  
Retruns Overlay bounds in geographical coordinates.
Marker
  
getBoundsXY(zoom:Number = 0):Bounds
Retruns Overlay bounds in bitmap coordinates.
Marker
  
[static] Return the default MarkerStyle object that will be used when creating any Marker.
Marker
  
getScale():Object
Gets the scale of the icon.
Marker
  
getStyle():Object
Returns a copy of the style object.
Marker
  
hide():void
Hides overlay.
Marker
 Inherited
invalidate():void
Schedules the Overlay for invalidation in 1 frame after this call.
Overlay
  
loadCustomIcon(icon:*):Boolean
Loads a custom icon for this Marker.
Marker
  
openInfoWindow(param:Object = null, style:Object = null):IInfoWindow
Opens new info window with the specified parameters & style.
Marker
  
redraw():void
Redraws the overlay.
Marker
  
refresh(full:Boolean = false):void
Refreshes overlay position on the map.
Marker
 Inherited
remove():void
Removes the object from the owner container object.
MapObject
  
Removes a custom icon loaded by the Marker.
Marker
  
removeEventListeners(target:InteractiveObject = null):void
Removes a built-in listener for MouseEvents fired by an InteractiveObject contained in the Overlay.
Marker
  
setDefaultStyle(style:Object):void
[static] Sets the default style for this Marker from an Object or another Style.
Marker
 Inherited
Adds the object to the specified IMapObjectContainer.
MapObject
  
setScale(scaleX:Number, scaleY:Number):void
Sets the scale of the icon.
Marker
  
setStyle(style:Object):void
Sets the style for this Overlay from an Object or another Style.
Marker
  
show():void
Shows overlay.
Marker
 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.
Marker
 Inherited
updateMapType(mapType:IMapType):void
Invoked when map type has been changed.
Overlay
 Inherited
updatePosition(latlng:LatLng):void
Invoked when map center has been updated.
Overlay
 Inherited
updateZoom(zoom:Number):void
Invoked when map zoom has been updated.
Overlay
Events
 EventSummaryDefined by
 Inherited Dispatched when the InfoWindow has been closed with the Overlay Overlay
 Inherited Dispatched when the InfoWindow has been opened with the Overlay Overlay
 Inherited Dispatched when an Overlay position is about to be refreshed.Overlay
 Inherited Dispatched when overlay has been added to a MapObjectContainer, e.g.Overlay
 Inherited Dispatched when an Overlay is about to be invalidated.Overlay
 Inherited Dispatched when an Overlay has been changed.Overlay
 Inherited Dispatched when user drags an Overlay.Overlay
 Inherited Dispatched when user starts dragging an Overlay.Overlay
 Inherited Dispatched when user stops dragging an Overlay.Overlay
 Inherited Dispatched when an Overlay has become invisible.Overlay
 Inherited Dispatched when user presses a mouse button over an Overlay.Overlay
 Inherited Dispatched when user moves the mouse over an Overlay.Overlay
 Inherited Dispatched when user releases a mouse button over an Overlay.Overlay
 Inherited Dispatched when an Overlay enters ready state.Overlay
 Inherited Dispatched when an Overlay has been invalidated.Overlay
 Inherited Dispatched when an Overlay position has been refreshed.Overlay
 Inherited Dispatched when user rolls out an Overlay.Overlay
 Inherited Dispatched when user rolls over an Overlay.Overlay
 Inherited Dispatched when an Overlay has become visible.Overlay
Property detail
enabledproperty
enabled:Boolean  [read-write]

Implementation
    public function get enabled():Boolean
    public function set enabled(value:Boolean):void
iconproperty 
icon:DisplayObject  [read-only]

Returns a reference to a custom icon object. It will be either a Sprite/MovieClip or a Loader object. Please note that icon will be available only after the OverlayEvent.READY event will be dispatched.

Implementation
    public function get icon():DisplayObject
iconLoaderproperty 
iconLoader:Loader  [read-only]

Returns a reference to a Loader object used by this Marker for loading external icons.

Implementation
    public function get iconLoader():Loader
indexproperty 
index:String  [read-write]

Gets or sets the index property of the Marker.

The default value is "".

Implementation
    public function get index():String
    public function set index(value:String):void
Constructor detail
Marker()constructor
public function Marker(param:Object = null, style:Object = null)

Marker constructor.

Creates new Marker object with the default parameters. Properties defined in param object will override the default values. You can also specify a Marker Style object that defines Marker appearence.

Parameters
param:Object (default = null) — Object that holds all the properites of a marker you wish to override upon its creation.
 
style:Object (default = null) — Object that defines marker's style.

See also


Example
Here how you can create a marker:
  import com.afcomponents.umap.core.UMap;
  import com.afcomponents.umap.styles.GeometryStyle;
  import com.afcomponents.umap.overlays.Marker;
  import com.afcomponents.umap.types.LatLng;
   
  // create new UMap object
  var map:UMap = new UMap();
  map.setSize(300, 300);
  this.addChild(map);
   
  // create new marker
  map.addOverlay(new Marker({position:new LatLng(20,-40)}, {fill:GeometryStyle.RGB, fillRGB:0xffcc00}));
  

Method detail
clone()method
public override function clone():IOverlay

Creates an exact copy of this Overlay and returns it to the user. Please note that it doesn't attach new Overlay to the same or any other parent.

Returns
IOverlay — New Overlay with the same properties.
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, style:Object = null, classObject:Class = null):Marker

Creates new Marker from XML object in KML 2.1 format.

Parameters
xml:XML — XML object with root <Container> node which contains Style nodes and a single <Placemark> node.
 
param:Object (default = null) — Default parameter object that will be passed to the object's constructor.
 
style:Object (default = null) — Default style 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
Marker — New Marker object.

Example
Here is a sample KML structure:
  <!-- Container id="ID" -->               <!-- Document,Folder -->
   <Style id="placemarkStyle">
     <IconStyle id="ID">
       <color>ffffffff</color>    <!-- kml:color -->
       <colorMode>normal</colorMode>  <!-- kml:colorModeEnum:normal or random -->
  
       <!-- specific to IconStyle -->
       <scale>1</scale>                     <!-- float -->
       <heading>0</heading>                 <!-- float -->
       <Icon>                                     <!-- Custom icon -->
         <href>...</href>
       </Icon>
       <hotSpot x="0.5" y="0.5" xunits="fraction" yunits="fraction"/>   <!-- kml:vec2Type -->
     </IconStyle>
   </Style>
   <Placemark>
     <name>Placemark name</name>                       <!-- string -->
     <styleUrl>#placemarkStyle</styleUrl>              <!-- id of a Style -->
     <description>Placemark description</description>  <!-- string -->
     <Point>
       <coordinates>...</coordinates>       <!-- lng,lat -->
     </Point>
   </Placemark>
  <-- /Container -->

getBoundsLatLng()method 
public override function getBoundsLatLng():LatLngBounds

Retruns Overlay bounds in geographical coordinates.

Returns
LatLngBounds — Overlay bounding rectangle in geographical coordinates.
getBoundsXY()method 
public override function getBoundsXY(zoom:Number = 0):Bounds

Retruns Overlay bounds in bitmap coordinates. Use zoom parameter to specify zoom level for bounds conversion.

Parameters
zoom:Number (default = 0) — Defines the zoom level at which to perform bounds conversion; if omitted, current zoom level will be used.

Returns
Bounds — Overlay bounding rectangle in bitmap coordinates.
getDefaultStyle()method 
public static function getDefaultStyle():MarkerStyle

Return the default MarkerStyle object that will be used when creating any Marker.

Returns
MarkerStyle — The default Style object used for new Markers.
getScale()method 
public function getScale():Object

Gets the scale of the icon.

Returns
Object
getStyle()method 
public override function getStyle():Object

Returns a copy of the style object.

Returns
Object — A clone of the current style as a MarkerStyle object.
hide()method 
public override function hide():void

Hides overlay. Fires OverlayEvent.HIDE & OverlayEvent.CHAGNED events if visibility has been changed.

loadCustomIcon()method 
public function loadCustomIcon(icon:*):Boolean

Loads a custom icon for this Marker. If an icon was previously loaded by this method, it will be removed before loading the new one.

Icon can be setup with one of the following:

  • URL to an external image (String)
  • Qualified Class Name of a display object asset. (String)
  • Class referenece of a display object asset. (Class)
  • URLRequest object which defines uri of an external asset. (URLRequest)
  • DisplayObject instance. (DisplayObject)
  • OverlayEvent.READY event will be dispatched either after external asset has been loaded, or in 1 frame after attaching a local asset.

    Parameters
    icon:* — Defines the custom icon for this marker. See above for more info.

    Returns
    Boolean — A value of true if custom icon has changed; false if it has not.
    openInfoWindow()method 
    public override function openInfoWindow(param:Object = null, style:Object = null):IInfoWindow

    Opens new info window with the specified parameters & style. Info window is placed in the center of the object.

    Default info window parameters are stored in _infoParam property, but can be overriden by param parameter of the function call. Also you can define the default autoClose value within the parent layer's infoParam object.

    Style objects will be concatinated. Here is the order of concatination:

  • InfoWindow.getDefaultStyle() - info window default static style.
  • Layer.infoStyle - parent layer info style.
  • Overlay.infoStyle - local infoStyle property
  • style - style parameter of the function call.
  • Parameters
    param:Object (default = null) — Object that describes the parameters of the InfoWindow.
     
    style:Object (default = null) — Object that defines InfoWindow's style.

    Returns
    IInfoWindow — Reference to the opened info window object.

    See also

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

    Redraws the overlay.

    Override this method in your subclass and call super.redraw() immediately before actual redraw so that OverlayEvent.BEFORE_REDRAW event will be automatically fired. At the end of your drawing don't forget to manually fire OverlayEvent.REDRAW event.

    refresh()method 
    public override function refresh(full:Boolean = false):void

    Refreshes overlay position on the map. If the full paramter is set to true then bitmap coordinates for this overlay should be recalculated.

    Parameters
    full:Boolean (default = false) — Indicates whether to recalculate bitmap coordinats.
    removeCustomIcon()method 
    public function removeCustomIcon():void

    Removes a custom icon loaded by the Marker. Overrides MarkerStyle.icon property to the value of null.

    removeEventListeners()method 
    public override function removeEventListeners(target:InteractiveObject = null):void

    Removes a built-in listener for MouseEvents fired by an InteractiveObject contained in the Overlay.

    Parameters
    target:InteractiveObject (default = null) — Target InteractiveObject to which mouse events we should stop listening. By default listeners are removed from the Overlay itself.
    setDefaultStyle()method 
    public static function setDefaultStyle(style:Object):void

    Sets the default style for this Marker from an Object or another Style.

    Parameters
    style:Object — which contains style properties you wish to overwrite.
    setScale()method 
    public function setScale(scaleX:Number, scaleY:Number):void

    Sets the scale of the icon.

    Parameters
    scaleX:Number — Horizontal scale [0..1]
     
    scaleY:Number — Vertical scale [0..1]
    setStyle()method 
    public override function setStyle(style:Object):void

    Sets the style for this Overlay from an Object or another Style. After setting the style, Overlay will be invalidated.

    Parameters
    style:Object — which contains style properties you wish to overwrite.

    See also

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

    Shows overlay. Fires OverlayEvent.SHOW & OverlayEvent.CHAGNED events if visibility has been changed.

    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.