| Package | com.afcomponents.umap.overlays |
| Class | public class Marker |
| Inheritance | Marker Overlay MapObject flash.display.Sprite |
MarkerStyle object.
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:
See also
| Property | Defined by | ||
|---|---|---|---|
![]() | asDisplayObject : DisplayObject
Returns reference to the object as a DisplayObject instance.
| MapObject | |
![]() | autoCloseInfo : Boolean
Gets or sets the autCloseInfo flag, which indicates whether to close
info window automatically when user clicks somewhere on the map.
| Overlay | |
![]() | autoInfo : Boolean
Gets or sets the autInfo flag, which indicates whether to open info window automatically upon mouse click.
| Overlay | |
![]() | core : UMap
Returns reference to the core UMap object.
| MapObject | |
![]() | data : *
Gets or sets the data parameter of the Overlay.
| Overlay | |
![]() | description : String
Gets or sets the description text of the Overlay.
| Overlay | |
![]() | draggable : Boolean
Gets or sets Overlay's draggable property.
| Overlay | |
![]() | dragging : 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 | ||
![]() | id : uint
Gets or sets the ID of the object.
| MapObject | |
| index : String
Gets or sets the index property of the Marker.
| Marker | ||
![]() | info : IInfoWindow
Return referens to opened InfoWindow
| Overlay | |
![]() | infoParam : Object
Gets or sets the info window param object.
| Overlay | |
![]() | infoStyle : Object
Gets or sets the info window style object associated with the Overlay.
| Overlay | |
![]() | name : String
Gets or sets the name of the object.
| Overlay | |
![]() | owner : IMapObjectContainer
Returns reference to the owner container object.
| MapObject | |
![]() | point : Point
Returns the position of the Overlay in bitmap coordinates.
| Overlay | |
![]() | position : LatLng
Gets or set the geographical position of the Overlay.
| Overlay | |
![]() | smartPosition : Boolean
Gets or sets the smartPosition flag, which indicates whether to use smart positioning with the Overlay.
| Overlay | |
![]() | smartPositionOffset : Number | Overlay | |
![]() | visible : Boolean
Gets or sets the Overlay's visibility.
| Overlay | |
![]() | zIndexAuto : Boolean
Gets or sets zIndexAuto property which indicates wheter Overlay should be brought to front on mouse over event.
| Overlay | |
| Method | Defined by | ||
|---|---|---|---|
|
Marker(param:Object = null, style:Object = null)
Marker constructor.
| Marker | ||
![]() |
addEventListeners(target:InteractiveObject = null):void
Adds a built-in listener for MouseEvents fired by an InteractiveObject contained in the Overlay.
| Overlay | |
![]() |
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 | ||
![]() |
closeInfoWindow():void
Closes info window that is currently opened.
| Overlay | |
|
dispose():void
Releases all the resources accuired by the object.
| Marker | ||
![]() |
dragStart():void
Starts Overlay dragging.
| Overlay | |
![]() |
dragStop():void
Stops Overlay dragging.
| Overlay | |
|
[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 | ||
![]() |
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 | ||
![]() |
remove():void
Removes the object from the owner container object.
| MapObject | |
|
removeCustomIcon():void
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 | ||
![]() |
setOwner(owner:IMapObjectContainer):void
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 | ||
![]() |
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 | ||
![]() |
updatePosition(latlng:LatLng):void
Invoked when map center has been updated.
| Overlay | |
![]() |
updateZoom(zoom:Number):void
Invoked when map zoom has been updated.
| Overlay | |
| enabled | property |
enabled:Boolean [read-write]Implementation
public function get enabled():Boolean
public function set enabled(value:Boolean):void
| icon | property |
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.
public function get icon():DisplayObject
| iconLoader | property |
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
| index | property |
index:String [read-write]Gets or sets the index property of the Marker.
The default value is "".
public function get index():String
public function set index(value:String):void
| 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.
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
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}));
| clone | () | method |
public override function clone():IOverlayCreates 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.
ReturnsIOverlay —
New Overlay with the same properties.
|
| dispose | () | method |
public override function dispose():voidReleases all the resources accuired by the object.
| fromXML | () | method |
public static function fromXML(xml:XML, param:Object = null, style:Object = null, classObject:Class = null):MarkerCreates new Marker from XML object in KML 2.1 format.
Parametersxml: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.
|
Marker —
New Marker object.
|
<!-- 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():LatLngBoundsRetruns Overlay bounds in geographical coordinates.
ReturnsLatLngBounds —
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.
zoom:Number (default = 0) — Defines the zoom level at which to perform bounds conversion; if omitted, current zoom level will be used.
|
Bounds —
Overlay bounding rectangle in bitmap coordinates.
|
| getDefaultStyle | () | method |
public static function getDefaultStyle():MarkerStyleReturn the default MarkerStyle object that will be used when creating any Marker.
ReturnsMarkerStyle —
The default Style object used for new Markers.
|
| getScale | () | method |
public function getScale():ObjectGets the scale of the icon.
ReturnsObject |
| getStyle | () | method |
public override function getStyle():ObjectReturns a copy of the style object.
ReturnsObject — 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:*):BooleanLoads 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:
String)String)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.
Parametersicon:* — Defines the custom icon for this marker. See above for more info.
|
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):IInfoWindowOpens 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 propertystyle - style parameter of the function call.param:Object (default = null) — Object that describes the parameters of the InfoWindow.
|
|
style:Object (default = null) — Object that defines InfoWindow's style.
|
IInfoWindow —
Reference to the opened info window object.
|
See also
| redraw | () | method |
public override function redraw():voidRedraws 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 are recalculated.
Otherwise overlay will be repositioned using previuosly calculated coordinates.
full:Boolean (default = false) — Indicates whether to perform full refresh.
|
| 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):voidRemoves a built-in listener for MouseEvents fired by an InteractiveObject contained in the Overlay.
Parameterstarget: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):voidSets the default style for this Marker from an Object or another Style.
Parametersstyle:Object — which contains style properties you wish to overwrite.
|
| setScale | () | method |
public function setScale(scaleX:Number, scaleY:Number):voidSets the scale of the icon.
ParametersscaleX:Number — Horizontal scale [0..1]
|
|
scaleY:Number — Vertical scale [0..1]
|
| setStyle | () | method |
public override function setStyle(style:Object):voidSets the style for this Overlay from an Object or another Style. After setting the style, Overlay will be invalidated.
Parametersstyle: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.
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.
|
XML — XML object in KML 2.1 format.
|