Map
public class
loom.modestmaps.Map
Description
vim:et sts=4 sw=4 cindent: @ignore
@author migurski @author darren @author tom
loom.modestmaps.Map is the base class and interface for Modest Maps.
@description Map is the base class and interface for Modest Maps. Correctly attaching an instance of this Sprite subclass should result in a pannable map. Controls and event handlers must be added separately.
@usage import loom.modestmaps.Map; import loom.modestmaps.geo.Location; import loom.modestmaps.mapproviders.BlueMarbleMapProvider; ... var map:Map = new Map(640, 480, true, new BlueMarbleMapProvider()); addChild(map);
API overview
Constructor
Map
(
width: Number
,
height: Number
,
draggable: Boolean
,
mapProvider: IMapProvider
,
mapStage: Stage
,
rest: Vector.<Object>
)
Initialize the map: set properties, add a tile grid, draw it
Attributes
Public attributes
| MapStage: Stage | static |
| grid: TileGrid |
das grid |
| markerClip: MarkerClip |
markers are attached here |
| onExtentChange: MapExtentChange | |
| onMapRender: MapChange | |
| onPan: MapPan | |
| onProviderChange: MapProviderChange | |
| onResize: MapResize | |
| onZoom: MapZoom | |
| panFraction: Number |
fraction of width/height to pan panLeft, panRight, panUp, panDown |
| size: Point |
Protected attributes
Functions
Public functions
| calcLocationPoint ( location: Location , context: DisplayObject = null ): Void |
Get a point (x, y) for a location (lat, lon) in the context of a given clip |
| extentCoordinate ( extent: MapExtent ): Coordinate | |
| getCenter (): Location |
Return the current center location of the map |
| getCenterZoom (): Vector.<Object> |
Return the current center location and zoom of the map |
| getExtent (): MapExtent |
Return a MapExtent for the current map view |
| getHeight (): Number |
Get map height |
| getMapProvider (): IMapProvider |
Get a reference to the current map provider |
| getMarker ( id: String ): DisplayObject |
Get a marker with the given id if one was created |
| getRotation (): Number | |
| getWidth (): Number |
Get map width |
| getZoom (): Number |
Return the current zoom level of the map |
| getZoomFractional (): Number |
Return the fractional current zoom level of the map |
| locationsCoordinate ( locations: Vector.<Location> , fitWidth: Number = 0 , fitHeight: Number = 0 ): Coordinate | |
| panAndZoomBy ( sc: Number , location: Location , targetPoint: Point , duration: Number = ): Void |
zoom in or out by sc, moving the given location to the requested target |
| panAndZoomIn ( location: Location , targetPoint: Point ): Void |
zoom in and put the given location in the center of the screen, or optionally at the given targetPoint |
| panAndZoomOut ( location: Location , targetPoint: Point ): Void |
zoom out and put the given location in the center of the screen, or optionally at the given targetPoint |
| panBy ( px: Number , py: Number ): Void | |
| panDown ( event: Event = null ): Void |
Pan down by 1/3 (or panFraction) of the map height |
| panLeft ( event: Event = null ): Void |
Pan left by 1/3 (or panFraction) of the map width |
| panRight ( event: Event = null ): Void |
Pan left by 1/3 (or panFraction) of the map width |
| panUp ( event: Event = null ): Void |
Pan up by 1/3 (or panFraction) of the map height |
| pointLocation ( point: Point , context: DisplayObject = null ): Location |
Get a location (lat, lon) for a point (x, y) in the context of a given clip |
| putMarker ( location: Location , marker: DisplayObject = null ): Void |
Add a marker at the given location (lat, lon) |
| removeAllMarkers (): Void | |
| removeMarker ( id: String ): Void |
Remove a marker with the given id |
| rotateByAbout ( angle: Number , targetPoint: Point ): Void | |
| setCenter ( location: Location ): Void |
put the given location in the middle of the map |
| setCenterZoom ( location: Location , zoom: Number ): Void |
Based on a location and zoom level, determine appropriate initial tile coordinate and point using calculateMapCenter(), and inform the grid of tile coordinate and point by calling grid.resetTiles() |
| setExtent ( extent: MapExtent ): Void |
Based on an array of locations, determine appropriate map bounds using calculateMapExtent(), and inform the grid of tile coordinate and point by calling grid.resetTiles() |
| setMapProvider ( newProvider: IMapProvider ): Void |
Set a new map provider, repainting tiles and changing bounding box if necessary |
| setRotation ( angle: Number , targetPoint: Point ): Void |
rotate to angle (radians), keeping the requested point in the same place |
| setSize ( w: Number , h: Number ): Void |
Set new map size, dispatch MapEvent.RESIZED |
| setZoom ( zoom: Number ): Void |
Based on a zoom level, determine appropriate initial tile coordinate and point using calculateMapCenter(), and inform the grid of tile coordinate and point by calling grid.resetTiles() |
| zoomByAbout ( zoomDelta: Number , targetPoint: Point , duration: Number = ): Void |
zoom in or out by zoomDelta, keeping the requested point in the same place |
| zoomIn ( event: Event = null ): Void |
Zoom in by one zoom level (to 200%) immediately, rounding up to the nearest zoom level if we're currently between zooms |
| zoomInAbout ( targetPoint: Point , duration: Number = ): Void |
zoom in, keeping the requested point in the same place |
| zoomOut ( event: Event = null ): Void |
Zoom out by one zoom level (to 50%) immediately, rounding down to the nearest zoom level if we're currently between zooms |
| zoomOutAbout ( targetPoint: Point , duration: Number = ): Void |
zoom out, keeping the requested point in the same place |
Protected functions
Constructor
Map ( width: Number , height: Number , draggable: Boolean , mapProvider: IMapProvider , mapStage: Stage , rest: Vector.<Object> )
Initialize the map: set properties, add a tile grid, draw it. Default extent covers the entire globe, (+/-85, +/-180). @param Width of map, in pixels. @param Height of map, in pixels. @param Whether the map can be dragged or not. @param Desired map provider, e.g. Blue Marble. @param Either a MapExtent or a Location and zoom (comma separated) @see loom.modestmaps.core.TileGrid
Attributes
MapStage: Stage
static
base: DisplayObject
Inherited from DisplayObject
read-only
The topmost object in the display tree the object is part of.
blendEnabled: Boolean
Inherited from DisplayObject
Enables or disables blending. If set to false, there will be no blending and there may be performance gains.
blendMode: BlendMode
Inherited from DisplayObject
The default value is BlendMode.AUTO
The blend mode determines how the object is blended with the objects underneath.
See also:
loom2d.display.BlendMode
bounds: Rectangle
Inherited from DisplayObject
read-only
The bounds of the object relative to the local coordinates of the parent.
cacheAsBitmap: Boolean
Inherited from DisplayObject
If true, the untransformed contents get cached into a texture at render time.
The contents remain static until you turn off caching or use invalidateBitmapCache
to update the cache manually.
depth: Number
Inherited from DisplayObject
If depthSort is enabled on parent, this will be used to establish draw order. Higher values are drawn closer. Matching values have undefined order.
depthSort: Boolean
Inherited from DisplayObjectContainer
If depth sorting enabled, direct children will use their depth property to establish draw order.
hasVisibleArea: Boolean
Inherited from DisplayObject
read-only
Indicates if an object occupies any visible area. (Which is the case when its 'alpha', 'scaleX' and 'scaleY' values are not zero, and its 'visible' property is enabled.)
ignoreHitTestAlpha: Boolean
Inherited from DisplayObject
This can be used if you wish to have a DisplayObject with zero alpha still respond to hit tests
name: String
Inherited from DisplayObject
The name of the display object (default: null). Used by 'getChildByName()' of display object containers.
numChildren: Number
Inherited from DisplayObjectContainer
read-only
The number of children of this container.
onExtentChange: MapExtentChange
onMapRender: MapChange
onPan: MapPan
onProviderChange: MapProviderChange
onResize: MapResize
onZoom: MapZoom
panFraction: Number
The default value is 0.333333333
fraction of width/height to pan panLeft, panRight, panUp, panDown
parent: DisplayObjectContainer
Inherited from DisplayObject
pivotX: Number
Inherited from DisplayObject
The x coordinate of the object's origin in its own coordinate space (default: 0).
pivotY: Number
Inherited from DisplayObject
The y coordinate of the object's origin in its own coordinate space (default: 0).
root: DisplayObject
Inherited from DisplayObject
read-only
The root object the display object is connected to (ie: an instance of the class that was passed to the Starling constructor), or null if the object is not connected to the stage.
rotation: Number
Inherited from DisplayObject
The rotation of the object in radians, (In Loom2D, all angles are measured in radians.)
scale: Number
Inherited from DisplayObject
General scale factor. '1' means no scale, negative values flip the object. Use this when setting scaleX/scaleY explicitly is too verbose.
scaleX: Number
Inherited from DisplayObject
The horizontal scale factor. '1' means no scale, negative values flip the object.
scaleY: Number
Inherited from DisplayObject
The vertical scale factor. '1' means no scale, negative values flip the object.
size: Point
stage: Stage
Inherited from DisplayObject
read-only
The stage the display object is connected to, or null if it is not connected to the stage.
touchable: Boolean
Inherited from DisplayObject
Indicates if this object (and its children) will receive touch events.
transformationMatrix: Matrix
Inherited from DisplayObject
The transformation matrix of the object relative to its parent.
If you assign a custom transformation matrix, Starling will try to figure out
suitable values for x, y, scaleX, scaleY, and rotation.
However, if the matrix was created in a different way, this might not be possible.
In that case, Starling will apply the matrix, but not update the corresponding
properties.
visible: Boolean
Inherited from DisplayObject
The visibility of the object, An invisible object will be untouchable.
x: Number
Inherited from DisplayObject
The x coordinate of the object relative to the local coordinates of the parent.
y: Number
Inherited from DisplayObject
The y coordinate of the object relative to the local coordinates of the parent.
Protected attributes
Functions
addChild
(
child: DisplayObject
,
fireEvents: Boolean
= true
): DisplayObject
Inherited from DisplayObjectContainer
Adds a child to the container. It will be at the frontmost position.
Parameters
| child: DisplayObject | |
| fireEvents: Boolean = true |
addChildAt
(
child: DisplayObject
,
index: Number
,
fireEvents: Boolean
= true
): DisplayObject
Inherited from DisplayObjectContainer
Adds a child to the container at a certain index.
Parameters
| child: DisplayObject | |
| index: Number | |
| fireEvents: Boolean = true |
addEventListener
(
type: String
,
listener: Function
): Void
Inherited from EventDispatcher
Registers an event listener at a certain object.
Parameters
| type: String | |
| listener: Function |
addLMLChild
(
id: String
,
child: Object
): Void
Inherited from DisplayObjectContainer
Add a child to this LML node, identifying it by id.
Parameters
| id: String | |
| child: Object |
broadcastEvent
(
event: Event
): Void
Inherited from DisplayObjectContainer
Dispatches an event on all children (recursively). The event must not bubble.
Parameters
| event: Event |
broadcastEventWith
(
type: String
,
data: Object
= null
): Void
Inherited from DisplayObjectContainer
Dispatches an event with the given parameters on all children (recursively). The method uses an internal pool of event objects to avoid allocations.
Parameters
| type: String | |
| data: Object = null |
calcLocationPoint ( location: Location , context: DisplayObject = null ): Void
Get a point (x, y) for a location (lat, lon) in the context of a given clip.
Parameters
| location: Location | |
| context: DisplayObject = null |
Returns
| Void | Matching point. |
center
(): Void
Inherited from DisplayObject
Center the DisplayObject's pivot point using the width and height. This centers this object about its own origin based on its width and height.
contains
(
child: DisplayObject
): Boolean
Inherited from DisplayObjectContainer
Determines if a certain object is a child of the container (recursively).
Parameters
| child: DisplayObject |
dispatchEvent
(
event: Event
): Void
Inherited from EventDispatcher
Dispatches an event to all objects that have registered listeners for its type. If an event with enabled 'bubble' property is dispatched to a display object, it will travel up along the line of parents, until it either hits the root object or someone stops its propagation manually.
Parameters
| event: Event |
dispatchEventWith
(
type: String
,
bubbles: Boolean
= false
,
data: Object
= null
): Void
Inherited from EventDispatcher
Dispatches an event with the given parameters to all objects that have registered listeners for the given type. The method uses an internal pool of event objects to avoid allocations.
Parameters
| type: String | |
| bubbles: Boolean = false | |
| data: Object = null |
dispose
(): Void
Inherited from DisplayObject
Disposes all resources of the display object. GPU buffers are released, event listeners are removed, filters are disposed.
getBounds
(
targetSpace: DisplayObject
,
resultRect: Rectangle
= null
): Rectangle
Inherited from DisplayObject
Returns a rectangle that completely encloses the object as it appears in another coordinate system. If you pass a 'resultRectangle', the result will be stored in this rectangle instead of creating a new object.
Parameters
| targetSpace: DisplayObject | |
| resultRect: Rectangle = null |
getCenter (): Location
Return the current center location of the map.
Returns
| Location | center Location |
getCenterZoom (): Vector.<Object>
Return the current center location and zoom of the map.
Returns
| Vector | Array of center and zoom: [center location, zoom number]. |
getChildAt
(
index: Number
): DisplayObject
Inherited from DisplayObjectContainer
Returns a child object at a certain index.
Parameters
| index: Number |
getChildAtUnsafe
(
index: Number
): DisplayObject
Inherited from DisplayObjectContainer
Returns a child object at a certain index without doing bounds checks. For optimized use in cases where you are 100% about the index validity.
Parameters
| index: Number |
getChildByName
(
name: String
): DisplayObject
Inherited from DisplayObjectContainer
Returns a child object with a certain name (non-recursively).
Parameters
| name: String |
getChildIndex
(
child: DisplayObject
): Number
Inherited from DisplayObjectContainer
Returns the index of a child within the container, or "-1" if it is not found.
Parameters
| child: DisplayObject |
getExtent (): MapExtent
Return a MapExtent for the current map view. TODO: MapExtent needs adapting to deal with non-rectangular map projections
Returns
| MapExtent | MapExtent object |
getFullTypeName
(): String
Inherited from Object
native
Gets the fully qualified type name of the Object. The fully qualified type name includes the package of the type.
Returns
| String | fully qualified type name of the Object. |
getMapProvider (): IMapProvider
Get a reference to the current map provider.
See also:
loom.modestmaps.mapproviders.IMapProvider
Returns
| IMapProvider | Map provider. |
getMarker ( id: String ): DisplayObject
Get a marker with the given id if one was created.
Parameters
| id: String |
getTargetTransformationMatrix
(
targetSpace: DisplayObject
,
resultMatrix: Matrix
): Void
Inherited from DisplayObject
native
Parameters
| targetSpace: DisplayObject | |
| resultMatrix: Matrix |
getType
(): Type
Inherited from Object
native
Gets the Type that describes the Object.
Returns
| Type | The Type that describes the object. |
getTypeName
(): String
Inherited from Object
native
Gets the type name of the Object.
Returns
| String | type name of the Object. |
getZoomFractional (): Number
Return the fractional current zoom level of the map.
Returns
| Number | zoom number |
globalToLocal
(
globalPoint: Point
): Point
Inherited from DisplayObject
Transforms a point from global (stage) coordinates to the local coordinate system.
Parameters
| globalPoint: Point |
hasEventListener
(
type: String
): Boolean
Inherited from EventDispatcher
Returns if there are listeners registered for a certain event type.
Parameters
| type: String |
hitTest
(
localPoint: Point
,
forTouch: Boolean
= false
): DisplayObject
Inherited from DisplayObject
Returns the object that is found topmost beneath a point in local coordinates, or nil if the test fails. If "forTouch" is true, untouchable and invisible objects will cause the test to fail.
Parameters
| localPoint: Point | |
| forTouch: Boolean = false |
initializeLMLNode
(
id: String
): Void
Inherited from DisplayObject
Handle LML node initialization.
Parameters
| id: String |
invalidateBitmapCache
(): Void
Inherited from DisplayObject
native
Update the cached texture before the next render.
This function has no effect if cacheAsBitmap is turned off.
localToGlobal
(
localPoint: Point
): Point
Inherited from DisplayObject
Transforms a point from the local coordinate system to global (stage) coordinates.
Parameters
| localPoint: Point |
locationsCoordinate ( locations: Vector.<Location> , fitWidth: Number = 0 , fitHeight: Number = 0 ): Coordinate
Parameters
| locations: Vector.<Location> | |
| fitWidth: Number = 0 | |
| fitHeight: Number = 0 |
moveChildLast
(
child: DisplayObject
): Void
Inherited from DisplayObjectContainer
Moves a child to be the last object in the container.
Parameters
| child: DisplayObject |
panAndZoomBy ( sc: Number , location: Location , targetPoint: Point , duration: Number = ): Void
zoom in or out by sc, moving the given location to the requested target
Parameters
| sc: Number | |
| location: Location | |
| targetPoint: Point | |
| duration: Number = |
panAndZoomIn ( location: Location , targetPoint: Point ): Void
zoom in and put the given location in the center of the screen, or optionally at the given targetPoint
Parameters
| location: Location | |
| targetPoint: Point |
panAndZoomOut ( location: Location , targetPoint: Point ): Void
zoom out and put the given location in the center of the screen, or optionally at the given targetPoint
Parameters
| location: Location | |
| targetPoint: Point |
panDown ( event: Event = null ): Void
Pan down by 1/3 (or panFraction) of the map height.
Parameters
| event: Event = null |
panLeft ( event: Event = null ): Void
Pan left by 1/3 (or panFraction) of the map width.
Parameters
| event: Event = null |
panRight ( event: Event = null ): Void
Pan left by 1/3 (or panFraction) of the map width.
Parameters
| event: Event = null |
panUp ( event: Event = null ): Void
Pan up by 1/3 (or panFraction) of the map height.
Parameters
| event: Event = null |
pointLocation ( point: Point , context: DisplayObject = null ): Location
Get a location (lat, lon) for a point (x, y) in the context of a given clip.
Parameters
| point: Point | |
| context: DisplayObject = null |
Returns
| Location | Matching location. |
preinitializeLMLNode
(
id: String
): Void
Inherited from DisplayObject
Pre-initialize the LML node.
Parameters
| id: String |
putMarker ( location: Location , marker: DisplayObject = null ): Void
Add a marker at the given location (lat, lon)
Parameters
| location: Location | |
| marker: DisplayObject = null |
removeChild
(
child: DisplayObject
,
dispose: Boolean
= false
,
fireEvents: Boolean
= true
): DisplayObject
Inherited from DisplayObjectContainer
Removes a child from the container. If the object is not a child, nothing happens. If requested, the child will be disposed right away.
Parameters
| child: DisplayObject | |
| dispose: Boolean = false | |
| fireEvents: Boolean = true |
removeChildAt
(
index: Number
,
dispose: Boolean
= false
,
fireEvents: Boolean
= true
): DisplayObject
Inherited from DisplayObjectContainer
Removes a child at a certain index. Children above the child will move down. If requested, the child will be disposed right away.
Parameters
| index: Number | |
| dispose: Boolean = false | |
| fireEvents: Boolean = true |
removeChildren
(
beginIndex: Number
= 0
,
endIndex: Number
=
,
dispose: Boolean
= false
): Void
Inherited from DisplayObjectContainer
Removes a range of children from the container (endIndex included). If no arguments are given, all children will be removed.
Parameters
| beginIndex: Number = 0 | |
| endIndex: Number = | |
| dispose: Boolean = false |
removeEventListener
(
type: String
,
listener: Function
): Void
Inherited from EventDispatcher
Removes an event listener from the object.
Parameters
| type: String | |
| listener: Function |
removeEventListeners
(
type: String
= null
): Void
Inherited from EventDispatcher
Removes all event listeners with a certain type, or all of them if type is null. Be careful when removing all event listeners: you never know who else was listening.
Parameters
| type: String = null |
removeFromParent
(
dispose: Boolean
= false
): Void
Inherited from DisplayObject
Removes the object from its parent, if it has one.
Parameters
| dispose: Boolean = false |
removeLMLChildren
(): Void
Inherited from DisplayObjectContainer
Remove (and destroy) all LML children from this node.
rotateByAbout ( angle: Number , targetPoint: Point ): Void
Parameters
| angle: Number | |
| targetPoint: Point |
setCenter ( location: Location ): Void
put the given location in the middle of the map
Parameters
| location: Location |
setCenterZoom ( location: Location , zoom: Number ): Void
Based on a location and zoom level, determine appropriate initial tile coordinate and point using calculateMapCenter(), and inform the grid of tile coordinate and point by calling grid.resetTiles().
See also:
loom.modestmaps.Map#calculateMapExtent
loom.modestmaps.core.TileGrid#resetTiles
Parameters
| location: Location | |
| zoom: Number |
setChildIndex
(
child: DisplayObject
,
index: Number
): Void
Inherited from DisplayObjectContainer
Moves a child to a certain index. Children at and after the replaced position move up.
Parameters
| child: DisplayObject | |
| index: Number |
setChildrenUnsafe
(
ordered: Vector.<DisplayObject>
): Void
Inherited from DisplayObjectContainer
Parameters
| ordered: Vector.<DisplayObject> |
setExtent ( extent: MapExtent ): Void
Based on an array of locations, determine appropriate map bounds using calculateMapExtent(), and inform the grid of tile coordinate and point by calling grid.resetTiles(). Resulting map extent will ensure that all passed locations are visible.
See also:
loom.modestmaps.Map#calculateMapExtent
loom.modestmaps.core.TileGrid#resetTiles
Parameters
| extent: MapExtent | the minimum area to fit inside the map view |
setMapProvider ( newProvider: IMapProvider ): Void
Set a new map provider, repainting tiles and changing bounding box if necessary.
See also:
loom.modestmaps.mapproviders.IMapProvider
Parameters
| newProvider: IMapProvider |
setRotation ( angle: Number , targetPoint: Point ): Void
rotate to angle (radians), keeping the requested point in the same place
Parameters
| angle: Number | |
| targetPoint: Point |
setSize ( w: Number , h: Number ): Void
Set new map size, dispatch MapEvent.RESIZED. The MapEvent includes the newSize.
See also:
loom.modestmaps.events.MapEvent.RESIZED
Parameters
| w: Number | New map width. |
| h: Number | New map height. |
setZoom ( zoom: Number ): Void
Based on a zoom level, determine appropriate initial tile coordinate and point using calculateMapCenter(), and inform the grid of tile coordinate and point by calling grid.resetTiles().
See also:
loom.modestmaps.Map#calculateMapExtent
loom.modestmaps.core.TileGrid#resetTiles
Parameters
| zoom: Number |
sortChildren
(
compareFunction: Function
): Void
Inherited from DisplayObjectContainer
Sorts the children according to a given function (that works just like the sort function of the Vector class).
Parameters
| compareFunction: Function |
swapChildren
(
child1: DisplayObject
,
child2: DisplayObject
): Void
Inherited from DisplayObjectContainer
Swaps the indexes of two children.
Parameters
| child1: DisplayObject | |
| child2: DisplayObject |
swapChildrenAt
(
index1: Number
,
index2: Number
): Void
Inherited from DisplayObjectContainer
Swaps the indexes of two children.
Parameters
| index1: Number | |
| index2: Number |
toString
(): String
Inherited from Object
native
Returns a String that describes the Object. This can be overriden to provide extra details when printing objects using trace().
Returns
| String | String that described the Object. |
zoomByAbout ( zoomDelta: Number , targetPoint: Point , duration: Number = ): Void
zoom in or out by zoomDelta, keeping the requested point in the same place
Parameters
| zoomDelta: Number | |
| targetPoint: Point | |
| duration: Number = |
zoomIn ( event: Event = null ): Void
Zoom in by one zoom level (to 200%) immediately, rounding up to the nearest zoom level if we're currently between zooms.
Triggers MapEvent.START_ZOOMING and MapEvent.STOP_ZOOMING events.
Parameters
| event: Event = null | an optional event so that zoomIn can directly function as an event listener. |
zoomInAbout ( targetPoint: Point , duration: Number = ): Void
zoom in, keeping the requested point in the same place
Parameters
| targetPoint: Point | |
| duration: Number = |
zoomOut ( event: Event = null ): Void
Zoom out by one zoom level (to 50%) immediately, rounding down to the nearest zoom level if we're currently between zooms.
Triggers MapEvent.START_ZOOMING and MapEvent.STOP_ZOOMING events.
Parameters
| event: Event = null | an optional event so that zoomOut can directly function as an event listener. |