Packagecom.google.maps
Classpublic class Map
InheritanceMap Inheritance flash.display.Sprite
ImplementsIMap

This is the main class of the Maps API for Flash. Instantiate Map to create a map.



Public Properties
 PropertyDefined by
  countryCode : String
The desired map country code.
Map
  key : String
The map key.
Map
  language : String
The desired map language.
Map
  languages : String
[AIR only] Sets the user's preferred languages.
Map
  MERCATOR_PROJECTION : IProjection
[read-only] Retrieves Mercator projection.
Map
  overlayRaising : Boolean
Set to true to enable raising of overlays upon mouse-over.
Map
  url : String
The url parameter for use in AIR applications.
Map
  version : String
The desired map library version.
Map
Public Methods
 MethodDefined by
  
Map()
Constructor.
Map
  
addControl(control:IControl):void
Registers a new control.
Map
  
addMapType(newMapType:IMapType):void
Registers a new map type.
Map
  
addOverlay(overlay:IOverlay):void
Adds an overlay to the map.
Map
  
Removes all controls from the map.
Map
  
Removes all overlays from the map.
Map
  
closeInfoWindow():Boolean
Closes the information window.
Map
  
Checks whether continuous zoom is enabled.
Map
  
Checks whether control by keyboard is enabled.
Map
  
Checks whether center crosshairs are enabled.
Map
  
Disables continuous smooth zooming.
Map
  
Disables control by keyboard.
Map
  
Disables the center crosshairs.
Map
  
Disables dragging of the map.
Map
  
Disables zooming using a mouse's scroll wheel.
Map
  
draggingEnabled():Boolean
Checks whether dragging of the map is enabled.
Map
  
Enables continuous smooth zooming.
Map
  
Enables control by keyboard.
Map
  
Enables the center crosshairs.
Map
  
Enables dragging of the map.
Map
  
Enables zooming using a mouse's scroll wheel.
Map
  
fromLatLngToPoint(latLng:LatLng, opt_zoom:Number):Point
Returns x,y coordinates of specified lat, lng and zoom relative to the origin of the map's projection (the origin is the top left corner of the top left tile of the map for the specified map zoom level).
Map
  
fromLatLngToViewport(latLng:LatLng, opt_disablewrap:Boolean = false):Point
Returns the pixel coordinates for the specified latLng location in the coordinate system of the map's view port ([0,0] being the top left corner of the map object).
Map
  
fromPointToLatLng(pos:Point, opt_zoom:Number, opt_nowrap:Boolean = false):LatLng
Returns lat,lng coordinates of specified x, y and zoom.
Map
  
fromViewportToLatLng(pos:Point, opt_nowrap:Boolean = false):LatLng
Returns the lat-lng of the point at the given coordinates in the map's view port (the top left corner of the map object).
Map
  
Returns the highest resolution zoom level at which the given rectangular region fits in the map view.
Map
  
Retrieves coordinates of the center in the map view control.
Map
  
Retrieves the current map type.
Map
  
getDisplayObject():DisplayObject
Retrieves the display object that represents the map.
Map
  
Get the mouse double click mode.
Map
  
Gets the version of the implementation library SWF.
Map
  
Retrieves the version of the client interface.
Map
  
Returns the the visible rectangular region of the map view in geographical coordinates.
Map
  
getMapTypes():Array
Retrieves the list of the map types available for the location.
Map
  
getMaxZoomLevel(opt_mapType:IMapType = null, opt_point:LatLng = null):Number
Retrieves the maximum zoom level.
Map
  
getMinZoomLevel(opt_mapType:IMapType = null, opt_point:LatLng = null):Number
Retrieves the minimum zoom level.
Map
  
Retrieves the full set of options used by the map.
Map
  
Retrieves the pane manager for the map.
Map
  
Returns the projection being applied to the map.
Map
  
getSize():Point
Retrieves the map view size.
Map
  
getZoom():Number
Retrieves the map zoom level.
Map
  
isLoaded():Boolean
Checks whether the map has been initialized.
Map
  
Opens a simple information window at the given point.
Map
  
panBy(distance:Point):void
Starts a pan animation by the given distance in pixels.
Map
  
panTo(latLng:LatLng):void
Pans the map to the specified centre location.
Map
  
removeControl(control:IControl):void
Removes a control from the map.
Map
  
removeMapType(oldMapType:IMapType):void
Removes a registered map type.
Map
  
removeOverlay(overlay:IOverlay):void
Removes an overlay from the map.
Map
  
Returns map to the saved position.
Map
  
savePosition():void
Stores the current map position and zoom level for later recall by returnToSavedPosition.
Map
  
Checks whether scroll wheel zooming is enabled.
Map
  
setCenter(latLng:LatLng, opt_zoom:Number, opt_mapType:IMapType = null):void
Changes the centre point of the map.
Map
  
setDoubleClickMode(val:Number):void
Set the mouse double click mode.
Map
  
setInitOptions(options:MapOptions):void
Sets the options used to initialize the Map.
Map
  
setMapType(mapType:IMapType):void
Changes the map type for the map.
Map
  
setSize(newSize:Point):void
Sets the size of the map view.
Map
  
setZoom(level:Number, opt_doContinuousZoom:Boolean = false):void
Changes the zoom level for the map view control.
Map
  
unload():void
Removes the map from its parent and attempts to unload it to free up memory associated with the map.
Map
  
zoomIn(opt_latlng:LatLng = null, opt_doCenter:Boolean = false, opt_doContinuousZoom:Boolean = false):void
Zooms in the map by one zoom level if possible.
Map
  
zoomOut(opt_latlng:LatLng = null, opt_doContinuousZoom:Boolean = false):void
Zooms out the map by one zoom level if possible.
Map
Protected Methods
 MethodDefined by
  
callLater(call:Function):void
Map
  
clearWrapper():void
Remove all event listeners and clear the wrapper.
Map
  
delayCall(call:Function):void
Delay a method call until the next frame.
Map
Property detail
countryCodeproperty
countryCode:String  [read-write]

The desired map country code. If set this provides the country code used by default for geocoding and directions queries. In both instances, however, the default code may be overridden on an individual query basis.

Implementation
    public function get countryCode():String
    public function set countryCode(value:String):void

See also

ClientGeocoderOptions.countryCode.
DirectionsOptions.countryCode.
keyproperty 
key:String  [read-write]

The map key.

Implementation
    public function get key():String
    public function set key(value:String):void
languageproperty 
language:String  [read-write]

The desired map language. Note that we'd generally recommend that you not set this. If left null then the map will pick up its language from the user's browser settings. Before setting this you might first try changing your browser's preferred language setting to see how your map will appear to a user in a different country. Set this explicitly only if you are certain of the language in which all users will interact with your map. This will override the language used for button labels, geocoding and directions queries.

Implementation
    public function get language():String
    public function set language(value:String):void

See also

ClientGeocoderOptions.language.
DirectionsOptions.language.
languages.
languagesproperty 
languages:String  [read-write]

[AIR only] Sets the user's preferred languages.

Implementation
    public function get languages():String
    public function set languages(value:String):void

Example
Setting Map.languages in AIR using the user's preferred languages, as set through the operating system.
   import flash.system.Capabilities;
     :
   languages = Capabilities.languages.join(',');

MERCATOR_PROJECTIONproperty 
MERCATOR_PROJECTION:IProjection  [read-only]

Retrieves Mercator projection.

Implementation
    public function get MERCATOR_PROJECTION():IProjection
overlayRaisingproperty 
overlayRaising:Boolean  [read-write]

Set to true to enable raising of overlays upon mouse-over. If enabled then a mouse-over event over an overlay that supports it (only markers do at present) will bring that overlay to the top. By default overlay raising is enabled.

Implementation
    public function get overlayRaising():Boolean
    public function set overlayRaising(value:Boolean):void
urlproperty 
url:String  [read-write]

The url parameter for use in AIR applications.

Implementation
    public function get url():String
    public function set url(value:String):void
versionproperty 
version:String  [read-write]

The desired map library version.

Implementation
    public function get version():String
    public function set version(value:String):void
Constructor detail
Map()constructor
public function Map()

Constructor. When this runs none of the bindable variables has yet been initialized. We defer actions that depend upon them until we have been added to the stage.

Method detail
addControl()method
public function addControl(control:IControl):void

Registers a new control. This can be called before the MAP_READY event has been received.

Parameters
control:IControl — New control to register.

Example
   public class MyMap extends Map {
     public function MyMap() {
       super();
       addEventListener(MapEvent.MAP_READY, onMapReady);
       addControl(new MapTypeControl());
     }
   }

addMapType()method 
public function addMapType(newMapType:IMapType):void

Registers a new map type.

Parameters
newMapType:IMapType — New map type to register.
addOverlay()method 
public function addOverlay(overlay:IOverlay):void

Adds an overlay to the map.

Parameters
overlay:IOverlay — The overlay to be added to the map.

Example
   var marker:Marker = new Marker(
       new LatLng(48.858842, 2.346997),
       new MarkerOptions({ fillRGB: 0x004000,
                           name: "Paris, France",
                           description: "City on the Seine" }));
   map.addOverlay(marker);

callLater()method 
protected function callLater(call:Function):voidParameters
call:Function
clearControls()method 
public function clearControls():void

Removes all controls from the map.

clearOverlays()method 
public function clearOverlays():void

Removes all overlays from the map.

clearWrapper()method 
protected function clearWrapper():void

Remove all event listeners and clear the wrapper.

closeInfoWindow()method 
public function closeInfoWindow():Boolean

Closes the information window.

Returns
Boolean — true iff there was an info window to close.
continuousZoomEnabled()method 
public function continuousZoomEnabled():Boolean

Checks whether continuous zoom is enabled.

Returns
Boolean — true if continuous zoom is enabled.
controlByKeyboardEnabled()method 
public function controlByKeyboardEnabled():Boolean

Checks whether control by keyboard is enabled.

Returns
Boolean — true if control by keyboard is enabled.
crosshairsEnabled()method 
public function crosshairsEnabled():Boolean

Checks whether center crosshairs are enabled.

Returns
Boolean — true if center crosshairs are enabled.
delayCall()method 
protected function delayCall(call:Function):void

Delay a method call until the next frame.

Parameters
call:Function — Method to invoke in the next frame.
disableContinuousZoom()method 
public function disableContinuousZoom():void

Disables continuous smooth zooming.

disableControlByKeyboard()method 
public function disableControlByKeyboard():void

Disables control by keyboard.

disableCrosshairs()method 
public function disableCrosshairs():void

Disables the center crosshairs.

disableDragging()method 
public function disableDragging():void

Disables dragging of the map.

disableScrollWheelZoom()method 
public function disableScrollWheelZoom():void

Disables zooming using a mouse's scroll wheel.

draggingEnabled()method 
public function draggingEnabled():Boolean

Checks whether dragging of the map is enabled.

Returns
Boolean — true if dragging of the map is enabled.
enableContinuousZoom()method 
public function enableContinuousZoom():void

Enables continuous smooth zooming.

enableControlByKeyboard()method 
public function enableControlByKeyboard():void

Enables control by keyboard.

enableCrosshairs()method 
public function enableCrosshairs():void

Enables the center crosshairs.

enableDragging()method 
public function enableDragging():void

Enables dragging of the map.

enableScrollWheelZoom()method 
public function enableScrollWheelZoom():void

Enables zooming using a mouse's scroll wheel.

fromLatLngToPoint()method 
public function fromLatLngToPoint(latLng:LatLng, opt_zoom:Number):Point

Returns x,y coordinates of specified lat, lng and zoom relative to the origin of the map's projection (the origin is the top left corner of the top left tile of the map for the specified map zoom level).

Parameters
latLng:LatLng — latLng location on the map
 
opt_zoom:Number — target zoom level (defaults to current zoom level)

Returns
Point — Point object with x and y properties
fromLatLngToViewport()method 
public function fromLatLngToViewport(latLng:LatLng, opt_disablewrap:Boolean = false):Point

Returns the pixel coordinates for the specified latLng location in the coordinate system of the map's view port ([0,0] being the top left corner of the map object).

Parameters
latLng:LatLng — LatLng coordinate of the point on the map.
 
opt_disablewrap:Boolean (default = false) — Whether wrapping of the map around +180/-180 degree longtitude is disabled.

Depending on the value of this parameter, the call may return the same or two different pixel coordinates depending on whether or not the shortest path between the current centre of the map and the target location crosses the +180/-180 degree longtitude wrap-around.

For example, the map is currently centred at Sydney, Australia [LatLng(-33.857, 151.215)] and the location passed into this call is San Francisco, USA [LatLng(37.779, -122.420)] This call will return two different pixel coordinates for the two values of the opt_disablewrap parameter.

By default (opt_disablewrap set to false), the map will wrap the around the +180/-180 degree longtitude to return the pixel coordinate that will lie to the right of the current centre of the map (picking the shorter path from Sydney to San Francisco that goes across the Pacific Ocean).

If the wrapping of the map is disabled (opt_disablewrap set to true), the pixel coordinate returned by the call will be to the left of the current centre (the longer path from Sydney to San Francisco going across the Indian and Atlantic Oceans).

The value returned by the call will be the same for either value of opt_disablewrap parameter if the shorter path from the current centre of the map to the target point does not cross the +180/-180 degree longtitude (such as in case where the current centre of the map is Sydney, Australia while the target location is Tokyo, Japan).

Returns
Point
fromPointToLatLng()method 
public function fromPointToLatLng(pos:Point, opt_zoom:Number, opt_nowrap:Boolean = false):LatLng

Returns lat,lng coordinates of specified x, y and zoom. The coordinates are relative to the origin of the map's projection (the top left corner of the top left tile of the map for the specified zoom level).

Parameters
pos:Point — x, y of a point
 
opt_zoom:Number — target zoom level (defaults to the current zoom level)
 
opt_nowrap:Boolean (default = false) — Do not wrap longitudes outside of [-180, 180)

Returns
LatLng — LatLng object with lat and lng
fromViewportToLatLng()method 
public function fromViewportToLatLng(pos:Point, opt_nowrap:Boolean = false):LatLng

Returns the lat-lng of the point at the given coordinates in the map's view port (the top left corner of the map object).

Parameters
pos:Point — Coordinates in the map's view port.
 
opt_nowrap:Boolean (default = false) — Do not wrap longitudes outside of [-180, 180)

Returns
LatLng — LatLng of the specified view port coordinates.
getBoundsZoomLevel()method 
public function getBoundsZoomLevel(bounds:LatLngBounds):Number

Returns the highest resolution zoom level at which the given rectangular region fits in the map view. The zoom level is computed for the currently selected map type.

Parameters
bounds:LatLngBounds — Bounds to show.

Returns
Number — Required zoom level to show these bounds.
getCenter()method 
public function getCenter():LatLng

Retrieves coordinates of the center in the map view control.

Returns
LatLng — LatLng for the center of the map view control.
getCurrentMapType()method 
public function getCurrentMapType():IMapType

Retrieves the current map type.

Returns
IMapType — Current map type.
getDisplayObject()method 
public function getDisplayObject():DisplayObject

Retrieves the display object that represents the map.

Returns
DisplayObject — Map display object
getDoubleClickMode()method 
public function getDoubleClickMode():Number

Get the mouse double click mode.

Returns
Number — mouse double click mode (one of the MapAction constants).

See also

getImplementationVersion()method 
public function getImplementationVersion():String

Gets the version of the implementation library SWF.

Returns
String — Version of the implementation library SWF.
getInterfaceVersion()method 
public function getInterfaceVersion():String

Retrieves the version of the client interface.

Returns
String — Client interface version.
getLatLngBounds()method 
public function getLatLngBounds():LatLngBounds

Returns the the visible rectangular region of the map view in geographical coordinates.

Returns
LatLngBounds — Lat-Lng for the visible map rectangle.
getMapTypes()method 
public function getMapTypes():Array

Retrieves the list of the map types available for the location.

Returns
Array — Array of available map types
getMaxZoomLevel()method 
public function getMaxZoomLevel(opt_mapType:IMapType = null, opt_point:LatLng = null):Number

Retrieves the maximum zoom level.

Parameters
opt_mapType:IMapType (default = null) — Map type used to determine maximum resolution.
 
opt_point:LatLng (default = null) — Point for which to get the maximum zoom.

Returns
Number — The maximum zoom level.
getMinZoomLevel()method 
public function getMinZoomLevel(opt_mapType:IMapType = null, opt_point:LatLng = null):Number

Retrieves the minimum zoom level.

Parameters
opt_mapType:IMapType (default = null) — MapType to determine minimum resolution.
 
opt_point:LatLng (default = null) — Point to get minimum zoom level for.

Returns
Number — The minimum zoom level.
getOptions()method 
public function getOptions():MapOptions

Retrieves the full set of options used by the map. Note that since MapOptions is used only during map initialization, this method only allows those original settings to be retrieved and does not support re-configuration of the map.

Returns
MapOptions — Options used by the map.

See also

Map.setInitOptions()
getPaneManager()method 
public function getPaneManager():IPaneManager

Retrieves the pane manager for the map.

Returns
IPaneManager — The instance of pane manager.

See also

getProjection()method 
public function getProjection():IProjection

Returns the projection being applied to the map.

Returns
IProjection — Projection being applied to the map.
getSize()method 
public function getSize():Point

Retrieves the map view size.

Returns
Point — Map view size.
getZoom()method 
public function getZoom():Number

Retrieves the map zoom level.

Returns
Number — Zoom level for the map.
isLoaded()method 
public function isLoaded():Boolean

Checks whether the map has been initialized.

Returns
Boolean — Returns true iff the map was initialized by a call to setCenter() since it was created.
openInfoWindow()method 
public function openInfoWindow(latlng:LatLng, options:InfoWindowOptions = null):IInfoWindow

Opens a simple information window at the given point.

Parameters
latlng:LatLng — Point at which the info window is opened.
 
options:InfoWindowOptions (default = null) — Info window options.

Returns
IInfoWindow — Reference to newly created info window.
panBy()method 
public function panBy(distance:Point):void

Starts a pan animation by the given distance in pixels.

Parameters
distance:Point — Distance in pixels
panTo()method 
public function panTo(latLng:LatLng):void

Pans the map to the specified centre location.

Parameters
latLng:LatLng — Coordinates for the new centre.
removeControl()method 
public function removeControl(control:IControl):void

Removes a control from the map. If the control was not added to the map, this does nothing.

Parameters
control:IControl — The control to remove.
removeMapType()method 
public function removeMapType(oldMapType:IMapType):void

Removes a registered map type.

Parameters
oldMapType:IMapType — Map type to unregister.
removeOverlay()method 
public function removeOverlay(overlay:IOverlay):void

Removes an overlay from the map.

Parameters
overlay:IOverlay — Overlay to be removed from the map.
returnToSavedPosition()method 
public function returnToSavedPosition():void

Returns map to the saved position.

savePosition()method 
public function savePosition():void

Stores the current map position and zoom level for later recall by returnToSavedPosition.

scrollWheelZoomEnabled()method 
public function scrollWheelZoomEnabled():Boolean

Checks whether scroll wheel zooming is enabled.

Returns
Boolean — true if scroll wheel zooming is enabled.
setCenter()method 
public function setCenter(latLng:LatLng, opt_zoom:Number, opt_mapType:IMapType = null):void

Changes the centre point of the map.

Parameters
latLng:LatLng — Coordinates for the new centre.
 
opt_zoom:Number — New zoom level.
 
opt_mapType:IMapType (default = null) — New map type.
setDoubleClickMode()method 
public function setDoubleClickMode(val:Number):void

Set the mouse double click mode.

Parameters
val:Number — mouse double click mode (one of the MapAction constants).

See also

setInitOptions()method 
public function setInitOptions(options:MapOptions):void

Sets the options used to initialize the Map. You should ONLY call this method whilst handling a MapEvent.MAP_PREINITIALIZE event. Before this event values which you need for MapOptions properties may not themselves have been configured. After this event map initialization will have progressed past the point at which MapOptions properties are used.

Parameters
options:MapOptions — Instance of MapOptions that overrides the defaults used to initialize the map; or null to use only the default options.

See also

setMapType()method 
public function setMapType(mapType:IMapType):void

Changes the map type for the map.

Parameters
mapType:IMapType — Map type.
setSize()method 
public function setSize(newSize:Point):void

Sets the size of the map view.

Parameters
newSize:Point — New view size for the map.
setZoom()method 
public function setZoom(level:Number, opt_doContinuousZoom:Boolean = false):void

Changes the zoom level for the map view control.

Parameters
level:Number — New zoom level.
 
opt_doContinuousZoom:Boolean (default = false) — Whether the zoom operation should be continuous (provided that continuous zoom is enabled for the map).

See also

unload()method 
public function unload():void

Removes the map from its parent and attempts to unload it to free up memory associated with the map. The map object will no longer be usable after the call to this method.

zoomIn()method 
public function zoomIn(opt_latlng:LatLng = null, opt_doCenter:Boolean = false, opt_doContinuousZoom:Boolean = false):void

Zooms in the map by one zoom level if possible.

Parameters
opt_latlng:LatLng (default = null) — If set, this is the point around which we zoom. Otherwise we will zoom in around the center of the map.
 
opt_doCenter:Boolean (default = false) — If true, we also want to center at opt_latlng.
 
opt_doContinuousZoom:Boolean (default = false) — Whether the zoom operation should be continuous (provided that continuous zoom is enabled for the map).

See also

zoomOut()method 
public function zoomOut(opt_latlng:LatLng = null, opt_doContinuousZoom:Boolean = false):void

Zooms out the map by one zoom level if possible.

Parameters
opt_latlng:LatLng (default = null) — If set, this is the point around which we zoom. Otherwise we will zoom out around the center of the map.
 
opt_doContinuousZoom:Boolean (default = false) — Whether the zoom operation should be continuous (provided that continuous zoom is enabled for the map).

See also