API Documentation | All Packages | All Classes | Index | Frames No Frames |
Class Map

Package | org.openscales.core
Class | public class Map
Inheritance | Map flash.display.Sprite

Instances of Map are interactive maps that can be embedded in a web pages or in Flex or AIR applications. Create a new map with the Map constructor. To extend a map, it's necessary to add controls (Control), handlers (Handler) and layers (Layer) to the map. Map is a pure ActionScript class. Flex wrapper and components can be found in the openscales-fx module.

Public Properties

| Property | Defined by
--- | --- | ---
|  | baseLayer : Layer The currently selected base layer. | Map
|  | bitmapTransition : DraggableSprite | Map
|  | center : LonLat Map center coordinates. | Map
|  | configuration : IConfiguration | Map
|  | controls : Array [read-only] Map controls | Map
|  | extent : Bounds [read-only] | Map
|  | featureLayers : Array [read-only] | Map
|  | handlers : Array [read-only] Map handlers | Map
|  | height : Number [write-only] Map height in pixels. | Map
|  | IMAGE_RELOAD_ATTEMPTS : Number = 0 | Map
|  | layerContainer : DraggableSprite [read-only] Map container where layers are added. | Map
|  | layers : Array [read-only] | Map
|  | loadComplete : Boolean [read-only] Whether or not the map is loading data | Map
|  | maxExtent : Bounds The maximum extent for the map. | Map
|  | proxy : String Proxy (usually a PHP, Python, or Java script) used to request remote servers like WFS servers in order to allow crossdomain requests. | Map
|  | resolution : Number [read-only] | Map
|  | scale : Number [read-only] | Map
|  | size : Size Map size in pixels. | Map
|  | tweenZoomEnabled : Boolean | Map
|  | width : Number [write-only] Map width in pixels. | Map
|  | zoom : Number Current map zoom level. | Map

Protected Properties

| Property | Defined by
--- | --- | ---
|  | loading : Boolean [write-only] Used to set loading status of map | Map

Public Methods

| Method | Defined by
--- | --- | ---
|  | Map(width:Number = 600, height:Number = 400) Map constructor | Map
|  | addControl(control:IControl, attach:Boolean = true):void Add a new control to the map. | Map
|  | addHandler(handler:IHandler):void Register a handler as one of the handlers of the map. | Map
|  | addLayer(layer:Layer):Boolean Add a new layer to the map. | Map
|  | addLayers(layers:Array):void Add a group of layers. | Map
|  | addPopup(popup:Popup, exclusive:Boolean = true):void | Map
|  | addSecurities(securities:Array):Boolean To add a securities Array | Map
|  | addSecurity(security:ISecurity):Boolean To add a security | Map
|  | findSecurityByClass(securityClass:String):ISecurity find a security requester by its class name | Map
|  | getLayerByName(name:String):Layer Get a layer from its name. | Map
|  | getLayerPxFromLonLat(lonlat:LonLat):Pixel Return a layer Pixel computed from a LonLat. | Map
|  | getLayerPxFromMapPx(mapPx:Pixel):Pixel Return a layer Pixel computed from a map Pixel. | Map
|  | getLonLatFromLayerPx(px:Pixel):LonLat Return a LonLat computed from a layer Pixel. | Map
|  | getLonLatFromMapPx(px:Pixel):LonLat Return a LonLat which is the passed-in view port Pixel, translated into lon/lat by the current base layer | Map
|  | getMapPxFromLayerPx(layerPx:Pixel):Pixel Return a map Pixel computed from a layer Pixel. | Map
|  | getMapPxFromLonLat(lonlat:LonLat):Pixel Return a Pixel which is the passed-in LonLat, translated into map pixels by the current base layer | Map
|  | getZoomForResolution(resolution:Number):Number A suitable zoom level for the specified bounds. | Map
|  | pan(dx:int, dy:int, tween:Boolean = false):void Allows user to pan by a value of screen pixels. | Map
|  | removeAllLayers():void | Map
|  | removeHandler(handler:IHandler):void Unregister a handler as one of the handlers of the map. | Map
|  | removeLayer(layer:Layer, setNewBaseLayer:Boolean = true):void Removes a layer from the map by removing its visual element, then removing it from the map's internal list of layers, setting the layer's map property to null. | Map
|  | removePopup(popup:Popup):void | Map
|  | removeSecurity(security:ISecurity):Boolean Remove a Security | Map
|  | resetCenterLayerContainer(tween:Boolean = true):void Reset the bitmap center depending on the current map center | Map
|  | setCenter(lonlat:LonLat, zoom:Number, dragging:Boolean = false, forceZoomChange:Boolean = false, dragTween:Boolean = false, resizing:Boolean = false):void Set the map center (and optionally, the zoom level). | Map
|  | zoomToExtent(bounds:Bounds):void Zoom to the passed in bounds, recenter. | Map
|  | zoomToMaxExtent():void Zoom to the full extent and recenter. | Map

Property detail

baseLayer | property

`baseLayer:Layer` [read-write]

The currently selected base layer. A BaseLayer is a special kind of Layer that determines the projection, min/max zoom level, etc...

Implementation
`public function get baseLayer():Layer`
`public function set baseLayer(value:Layer):void`

bitmapTransition | property |

`bitmapTransition:DraggableSprite` [read-write]Implementation
`public function get bitmapTransition():DraggableSprite`
`public function set bitmapTransition(value:DraggableSprite):void`

center | property |

`center:LonLat` [read-write]

Map center coordinates.

Implementation
`public function get center():LonLat`
`public function set center(value:LonLat):void`

configuration | property |

`configuration:IConfiguration` [read-write]Implementation
`public function get configuration():IConfiguration`
`public function set configuration(value:IConfiguration):void`

controls | property |

`controls:Array` [read-only]

Map controls

Implementation
`public function get controls():Array`

extent | property |

`extent:Bounds` [read-only]Implementation
`public function get extent():Bounds`

featureLayers | property |

`featureLayers:Array` [read-only]Implementation
`public function get featureLayers():Array`

handlers | property |

`handlers:Array` [read-only]

Map handlers

Implementation
`public function get handlers():Array`

height | property |

`height:Number` [write-only]

Map height in pixels.

Implementation
`public function set height(value:Number):void`

IMAGE_RELOAD_ATTEMPTS | property |

`public var IMAGE_RELOAD_ATTEMPTS:Number = 0`

layerContainer | property |

`layerContainer:DraggableSprite` [read-only]

Map container where layers are added. It is used for panning and scaling layers.

Implementation
`public function get layerContainer():DraggableSprite`

layers | property |

`layers:Array` [read-only]Implementation
`public function get layers():Array`

loadComplete | property |

`loadComplete:Boolean` [read-only]

Whether or not the map is loading data

Implementation
`public function get loadComplete():Boolean`

loading | property |

`loading:Boolean` [write-only]

Used to set loading status of map

Implementation
`protected function set loading(value:Boolean):void`

maxExtent | property |

`maxExtent:Bounds` [read-write]

The maximum extent for the map.

Implementation
`public function get maxExtent():Bounds`
`public function set maxExtent(value:Bounds):void`

proxy | property |

`proxy:String` [read-write]

Proxy (usually a PHP, Python, or Java script) used to request remote servers like WFS servers in order to allow crossdomain requests. Remote servers can be used without proxy script by using crossdomain.xml file like http://openscales.org/crossdomain.xml

Implementation
`public function get proxy():String`
`public function set proxy(value:String):void`

resolution | property |

`resolution:Number` [read-only]Implementation
`public function get resolution():Number`

scale | property |

`scale:Number` [read-only]Implementation
`public function get scale():Number`

size | property |

`size:Size` [read-write]

Map size in pixels.

Implementation
`public function get size():Size`
`public function set size(value:Size):void`

tweenZoomEnabled | property |

`tweenZoomEnabled:Boolean` [read-write]Implementation
`public function get tweenZoomEnabled():Boolean`
`public function set tweenZoomEnabled(value:Boolean):void`

width | property |

`width:Number` [write-only]

Map width in pixels.

Implementation
`public function set width(value:Number):void`

zoom | property |

`zoom:Number` [read-write]

Current map zoom level.

Implementation
`public function get zoom():Number`
`public function set zoom(value:Number):void`
Constructor detail

Map | () | constructor

`public function Map(width:Number = 600, height:Number = 400)`

Map constructor

Parameters

| `width:Number` (default = `600`)`` — the map's width in pixels
| `height:Number` (default = `400`)`` — the map's height in pixels

Method detail

addControl | () | method

`public function addControl(control:IControl, attach:Boolean = true):void`

Add a new control to the map.

Parameters

| `control:IControl` — the control to add.
| `attach:Boolean` (default = `true`)`` — if true, the control will be added as child component of the map. This parameter may be for example set to false when adding a Flex component displayed outside the map.

addHandler | () | method |

`public function addHandler(handler:IHandler):void`

Register a handler as one of the handlers of the map. The handler must have its map property setted to this before. The handler is not automatically activated. If needed, you have to do it by using the active setter of the handler. This function should only be called by the Handler.map setter !

Parameters

| `handler:IHandler` — the handler to add.

addLayer | () | method |

`public function addLayer(layer:Layer):Boolean`

Add a new layer to the map. A LayerEvent.LAYER_ADDED event is triggered.

Parameters

| `layer:Layer` — The layer to add.

Returns

| `Boolean` — true if the layer have been added, false if it has not.

addLayers | () | method |

`public function addLayers(layers:Array):void`

Add a group of layers.

Parameters

| `layers:Array` — to add.

addPopup | () | method |

`public function addPopup(popup:Popup, exclusive:Boolean = true):void`

Parameters

| `popup:Popup` — popup
| `exclusive:Boolean` (default = `true`)`` — exclusive If true, closes all other popups first

addSecurities | () | method |

`public function addSecurities(securities:Array):Boolean`

To add a securities Array

Parameters

| `securities:Array` — The securities Array to add

Returns

| `Boolean` — Boolean true or false depends on the adding or not

addSecurity | () | method |

`public function addSecurity(security:ISecurity):Boolean`

To add a security

Parameters

| `security:ISecurity` — The security to add

Returns

| `Boolean` — Boolean true or false depends on the adding or not

findSecurityByClass | () | method |

`public function findSecurityByClass(securityClass:String):ISecurity`

find a security requester by its class name

Parameters

| `securityClass:String`

Returns

| `ISecurity` — the security

getLayerByName | () | method |

`public function getLayerByName(name:String):Layer`

Get a layer from its name.

Parameters

| `name:String` — the layer name to find.

Returns

| `Layer` — the found layer. Null if no layer have been found.

getLayerPxFromLonLat | () | method |

`public function getLayerPxFromLonLat(lonlat:LonLat):Pixel`

Return a layer Pixel computed from a LonLat.

Parameters

| `lonlat:LonLat`

Returns

| `Pixel`

getLayerPxFromMapPx | () | method |

`public function getLayerPxFromMapPx(mapPx:Pixel):Pixel`

Return a layer Pixel computed from a map Pixel.

Parameters

| `mapPx:Pixel`

Returns

| `Pixel`

getLonLatFromLayerPx | () | method |

`public function getLonLatFromLayerPx(px:Pixel):LonLat`

Return a LonLat computed from a layer Pixel.

Parameters

| `px:Pixel`

Returns

| `LonLat`

getLonLatFromMapPx | () | method |

`public function getLonLatFromMapPx(px:Pixel):LonLat`

Return a LonLat which is the passed-in view port Pixel, translated into lon/lat by the current base layer

Parameters

| `px:Pixel`

Returns

| `LonLat`

getMapPxFromLayerPx | () | method |

`public function getMapPxFromLayerPx(layerPx:Pixel):Pixel`

Return a map Pixel computed from a layer Pixel.

Parameters

| `layerPx:Pixel`

Returns

| `Pixel`

getMapPxFromLonLat | () | method |

`public function getMapPxFromLonLat(lonlat:LonLat):Pixel`

Return a Pixel which is the passed-in LonLat, translated into map pixels by the current base layer

Parameters

| `lonlat:LonLat`

Returns

| `Pixel`

getZoomForResolution | () | method |

`public function getZoomForResolution(resolution:Number):Number`

A suitable zoom level for the specified bounds. If no baselayer is set, returns null.

Parameters

| `resolution:Number` — the resolution to use

Returns

| `Number` — the matching zoom level

pan | () | method |

`public function pan(dx:int, dy:int, tween:Boolean = false):void`

Allows user to pan by a value of screen pixels.

Parameters

| `dx:int` — horizontal pixel offset
| `dy:int` — verticial pixel offset
| `tween:Boolean` (default = `false`)`` — use tween effect

removeAllLayers | () | method |

`public function removeAllLayers():void`

removeHandler | () | method |

`public function removeHandler(handler:IHandler):void`

Unregister a handler as one of the handlers of the map. The handler must have its map property setted null before or after. The handler is not automatically deactivated. You have to do it by using the active setter of the handler. This function should only be called by the Handler.map setter !

Parameters

| `handler:IHandler` — the handler to remove.

removeLayer | () | method |

`public function removeLayer(layer:Layer, setNewBaseLayer:Boolean = true):void`

Removes a layer from the map by removing its visual element, then removing it from the map's internal list of layers, setting the layer's map property to null. A LayerEvent.LAYER_REMOVED event is triggered.

Parameters

| `layer:Layer` — the layer to remove.
| `setNewBaseLayer:Boolean` (default = `true`)`` — if set to true, a new base layer will be set if the removed layer was a based layer

removePopup | () | method |

`public function removePopup(popup:Popup):void` Parameters

| `popup:Popup`

removeSecurity | () | method |

`public function removeSecurity(security:ISecurity):Boolean`

Remove a Security

Parameters

| `security:ISecurity` — security to remove

Returns

| `Boolean` — Boolean true or false depends on the success of removing

resetCenterLayerContainer | () | method |

`public function resetCenterLayerContainer(tween:Boolean = true):void`

Reset the bitmap center depending on the current map center

Parameters

| `tween:Boolean` (default = `true`)`` — use tween effect if set to true (default)

setCenter | () | method |

`public function setCenter(lonlat:LonLat, zoom:Number, dragging:Boolean = false, forceZoomChange:Boolean = false, dragTween:Boolean = false, resizing:Boolean = false):void`

Set the map center (and optionally, the zoom level). This method shoud be refactored in order to make panning and zooming more independant.

Parameters

| `lonlat:LonLat` — the new center location.
| `zoom:Number` — optional zoom level
| `dragging:Boolean` (default = `false`)`` — Specifies whether or not to trigger movestart/end events
| `forceZoomChange:Boolean` (default = `false`)`` — Specifies whether or not to trigger zoom change events (needed on baseLayer change)
| `dragTween:Boolean` (default = `false`)``
| `resizing:Boolean` (default = `false`)``

zoomToExtent | () | method |

`public function zoomToExtent(bounds:Bounds):void`

Zoom to the passed in bounds, recenter.

Parameters

| `bounds:Bounds`

zoomToMaxExtent | () | method |

`public function zoomToMaxExtent():void`

Zoom to the full extent and recenter.