Packagecom.yahoo.maps.api
Classpublic class YahooMap
InheritanceYahooMap Inheritance flash.display.Sprite
ImplementsIYahooMap

Yahoo! Maps API Service Class. This object is the main entrypoint into the API.


Example
The following code creates a new YahooMap object and sets an initial location and zoom level.
  package {
   import com.yahoo.maps.api.YahooMap;
   import com.yahoo.maps.api.YahooMapEvent;
   import com.yahoo.maps.api.core.location.LatLon;
  
   import flash.display.Sprite;
   import flash.display.StageAlign;
   import flash.display.StageScaleMode;
  
   public class YahooMapExample extends Sprite
   {
    private var _map:YahooMap;
   
     private static const APPID:String = "<your appid here>"; // Important, replace this value with your own application ID.
   
     public function YahooMapExample()
     {
      this.stage.scaleMode = StageScaleMode.NO_SCALE;
      this.stage.align = StageAlign.TOP_LEFT;
    
      _map = new YahooMap();
      _map.addEventListener(YahooMapEvent.MAP_INITIALIZE, handleMapInitialize);
      _map.init(APPID, this.stage.stageWidth, this.stage.stageHeight);
    
      this.addChild(_map);
     }
   
     private function handleMapInitialize(event:YahooMapEvent):void
     {
      _map.addPanControl();
    
      _map.zoomLevel = 6;
      _map.centerLatLon = new LatLon(34.01,-118.49);
     }
    }
   }
  



Public Properties
 PropertyDefined by
  appid : String
Your application ID.
YahooMap
  centerLatLon : LatLon
The center LatLon point of the map.
YahooMap
  centerOnDoubleClick : Boolean
Whether the map should automatically center on a double click event.
YahooMap
  config : MapConfig
[read-only] A reference to the MapConfig object.
YahooMap
  container : DisplayObject
[read-only]
YahooMap
  crosshairWidget : CrosshairWidget
[read-only] The CrossHairWidget for the map.
YahooMap
  height : Number
The height of the map.
YahooMap
  initialized : Boolean
[read-only] Returns false if the map has not yet been initialized.
YahooMap
  keyboardControlsEnabled : Boolean
Enabled status of the MapKeyboardManager
YahooMap
  mapBase : MapBase
[read-only] The MapBase object containing the tile matrix.
YahooMap
  mapContainer : Sprite
[read-only] A Sprite containing the MapBase object
YahooMap
  mapHeight : Number
[read-only] The height of the map.
YahooMap
  mapType : String
The current map type
YahooMap
  mapTypeWidget : MapTypeWidget
[read-only] The MapTypeControl widget for the map.
YahooMap
  mapWidth : Number
[read-only] The width of the map.
YahooMap
  markerContainer : Sprite
[read-only] A Sprite which contains the markers added to the map view.
YahooMap
  markerManager : MarkerManager
[read-only] The maps MarkerManager
YahooMap
  overlayContainer : Sprite
[read-only] A Sprite which contains the overlays added to the map view.
YahooMap
  overlayManager : OverlayManager
[read-only] The maps OverlayManager
YahooMap
  panControl : PanControl
[read-only] Returns the PanControl object for the map.
YahooMap
  scaleBarWidget : ScaleBarWidget
[read-only] The ScaleBarWidget for the map.
YahooMap
  widgetContainer : Sprite
[read-only] A Sprite which contains the widgets added to the map view.
YahooMap
  width : Number
The width of the map.
YahooMap
  zoomLevel : int
The current zoom level of the map
YahooMap
  zoomWidget : ZoomWidget
[read-only] The ZoomControl widget for the map.
YahooMap
Public Methods
 MethodDefined by
  
Creates a new YahooMap object
YahooMap
  
addCrosshair():void
Adds a crosshair widget to the center of the map.
YahooMap
  
Adds panning abilities to the map, allowing it to be dragged and clicked on.
YahooMap
  
addScaleBar():void
Adds the ScaleBarWidget to the maps widget container
YahooMap
  
Removes the MapTypeControl from the maps widget container
YahooMap
  
Adds the ZoomControl to the maps widget container
YahooMap
  
destroy():void
Prepares the map for garbage-collection by removing references to child objects and containers.
YahooMap
  
getFeetToPixels(feet:Number, latitude:Number):Number
Converts a value in feet to pixels.
YahooMap
  
getKilometersToPixels(kilometers:Number, latitude:Number):Number
Converts a value in kilometers to pixels.
YahooMap
  
getLatLonToTileXY(latlon:LatLon):TileXY
Converts a LatLon to a TileXY object
YahooMap
  
getLatLonToXY(latlon:LatLon):Point
Converts a LatLon object to a point
YahooMap
  
Retrieves the bounds of the map.
YahooMap
  
getMetersToPixels(meters:Number, latitude:Number):Number
Converts a value in meters to pixels.
YahooMap
  
getMilesToPixels(miles:Number, latitude:Number):Number
Converts a value in miles to pixels.
YahooMap
  
getVersion():String
The current version of the API.
YahooMap
  
getXYToLatLon(point:Point):LatLon
Converts a Point to a LatLon object
YahooMap
  
getZoomRange():Array
Returns an array of zoom levels allowed on the map base.
YahooMap
  
init(appid:String, width:Number, height:Number, locale:String = "en"):void
Initializes the map given a YDN application ID, width, height and locale.
YahooMap
  
panToLatLon(latlon:LatLon, duration:Number = 250):Object
Smoothly pans the map to the specified location.
YahooMap
  
Removes the crosshair widget from the map.
YahooMap
  
Removes panning abilities from the map.
YahooMap
  
Removes the ScaleBarWidget from the maps widget container
YahooMap
  
Adds the MapTypeControl to the maps widget container
YahooMap
  
Removes the ZoomControl from the maps widget container
YahooMap
  
setCenterAddress(address:Address):void
Sets the map center by geocoding the address provided, and setting the maps centerLatLon when the geocoder responds.
YahooMap
  
setCenterByPixels(point:Point):void
Shifts the maps center point by the assigned delta point
YahooMap
  
setCenterWoeId(woeid:uint):void
Sets the center of the map to the provided WhereOnEarth identifier.
YahooMap
  
setHandCursor(value:Boolean):void
Sets the hand cursor visibility over the map
YahooMap
  
Sets the bounds of the map.
YahooMap
  
setSize(width:Number, height:Number):void
Sets the map size.
YahooMap
  
setZoomRange(minZoomLevel:Number, maxZoomLevel:Number):void
Sets the range of zoom levels allowed on the map base.
YahooMap
Events
 EventSummaryDefined by
   Dispatched when the map configuration data fails to load or an error occured.YahooMap
   Dispatched when the map configuration data successfully loads.YahooMap
   Dispatched when a hybrid tile is loaded.YahooMap
   Dispatched when the map tile engine is initialized.YahooMap
   Dispatched when the map is being dragged.YahooMap
   Dispatched when the map starts dragging.YahooMap
   Dispatched when the map stops dragging.YahooMap
   Dispatched when the map is initialized and ready to be interacted with.YahooMap
   Dispatched when the map is clicked on.YahooMap
   Dispatched when the map is double-clicked on.YahooMap
   Dispatched when the mouse is pressed over the map.YahooMap
   Dispatched as the mouse moves over the map.YahooMap
   Dispatched when the mouse is released over the map.YahooMap
   Dispatched when the map is moved.YahooMap
   Dispatched when the map is resized.YahooMap
   Dispatched when a map or satellite tile is loaded.YahooMap
   Dispatched when all tiles have been loaded.YahooMap
   Dispatched when the current map view type has been changed.YahooMap
   Dispatched when the maps zoom level is changed.YahooMap
   Dispatched when a tile fails to load.YahooMap
Property detail
appidproperty
appid:String  [read-write]

Your application ID.

Implementation
    public function get appid():String
    public function set appid(value:String):void
centerLatLonproperty 
centerLatLon:LatLon  [read-write]

The center LatLon point of the map.

Implementation
    public function get centerLatLon():LatLon
    public function set centerLatLon(value:LatLon):void

See also

LatLon
centerOnDoubleClickproperty 
centerOnDoubleClick:Boolean  [read-write]

Whether the map should automatically center on a double click event. (default=true)

Implementation
    public function get centerOnDoubleClick():Boolean
    public function set centerOnDoubleClick(value:Boolean):void
configproperty 
config:MapConfig  [read-only]

A reference to the MapConfig object.

Implementation
    public function get config():MapConfig
containerproperty 
container:DisplayObject  [read-only]Implementation
    public function get container():DisplayObject
crosshairWidgetproperty 
crosshairWidget:CrosshairWidget  [read-only]

The CrossHairWidget for the map. This may be null if it hasn't been added yet.

Implementation
    public function get crosshairWidget():CrosshairWidget
heightproperty 
height:Number  [read-write]

The height of the map.

Implementation
    public function get height():Number
    public function set height(value:Number):void
initializedproperty 
initialized:Boolean  [read-only]

Returns false if the map has not yet been initialized.

Implementation
    public function get initialized():Boolean
keyboardControlsEnabledproperty 
keyboardControlsEnabled:Boolean  [read-write]

Enabled status of the MapKeyboardManager

Implementation
    public function get keyboardControlsEnabled():Boolean
    public function set keyboardControlsEnabled(value:Boolean):void

See also

mapBaseproperty 
mapBase:MapBase  [read-only]

The MapBase object containing the tile matrix.

Implementation
    public function get mapBase():MapBase

See also

mapContainerproperty 
mapContainer:Sprite  [read-only]

A Sprite containing the MapBase object

Implementation
    public function get mapContainer():Sprite
mapHeightproperty 
mapHeight:Number  [read-only]

The height of the map.

Implementation
    public function get mapHeight():Number
mapTypeproperty 
mapType:String  [read-write]

The current map type

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

See also

mapTypeWidgetproperty 
mapTypeWidget:MapTypeWidget  [read-only]

The MapTypeControl widget for the map. This may be null if it hasn't been added yet.

Implementation
    public function get mapTypeWidget():MapTypeWidget

See also

mapWidthproperty 
mapWidth:Number  [read-only]

The width of the map.

Implementation
    public function get mapWidth():Number
markerContainerproperty 
markerContainer:Sprite  [read-only]

A Sprite which contains the markers added to the map view.

Implementation
    public function get markerContainer():Sprite
markerManagerproperty 
markerManager:MarkerManager  [read-only]

The maps MarkerManager

Implementation
    public function get markerManager():MarkerManager

See also

overlayContainerproperty 
overlayContainer:Sprite  [read-only]

A Sprite which contains the overlays added to the map view.

Implementation
    public function get overlayContainer():Sprite
overlayManagerproperty 
overlayManager:OverlayManager  [read-only]

The maps OverlayManager

Implementation
    public function get overlayManager():OverlayManager

See also

panControlproperty 
panControl:PanControl  [read-only]

Returns the PanControl object for the map.

Implementation
    public function get panControl():PanControl

See also

PanControl
scaleBarWidgetproperty 
scaleBarWidget:ScaleBarWidget  [read-only]

The ScaleBarWidget for the map. This may be null if it hasn't been added yet.

Implementation
    public function get scaleBarWidget():ScaleBarWidget

See also

widgetContainerproperty 
widgetContainer:Sprite  [read-only]

A Sprite which contains the widgets added to the map view.

Implementation
    public function get widgetContainer():Sprite
widthproperty 
width:Number  [read-write]

The width of the map.

Implementation
    public function get width():Number
    public function set width(value:Number):void
zoomLevelproperty 
zoomLevel:int  [read-write]

The current zoom level of the map

Implementation
    public function get zoomLevel():int
    public function set zoomLevel(value:int):void
zoomWidgetproperty 
zoomWidget:ZoomWidget  [read-only]

The ZoomControl widget for the map. This may be null if it hasn't been added yet.

Implementation
    public function get zoomWidget():ZoomWidget

See also

Constructor detail
YahooMap()constructor
public function YahooMap()

Creates a new YahooMap object

Method detail
addCrosshair()method
public function addCrosshair():void

Adds a crosshair widget to the center of the map. (Since v0.9.2)

addPanControl()method 
public function addPanControl():void

Adds panning abilities to the map, allowing it to be dragged and clicked on.

addScaleBar()method 
public function addScaleBar():void

Adds the ScaleBarWidget to the maps widget container

addTypeWidget()method 
public function addTypeWidget():void

Removes the MapTypeControl from the maps widget container

addZoomWidget()method 
public function addZoomWidget():void

Adds the ZoomControl to the maps widget container

destroy()method 
public function destroy():void

Prepares the map for garbage-collection by removing references to child objects and containers.

getFeetToPixels()method 
public function getFeetToPixels(feet:Number, latitude:Number):Number

Converts a value in feet to pixels.

Parameters
feet:Number — A distance in feet.
 
latitude:Number — The latitude in which to measure at. Defaults to the maps current center latitude.

Returns
Number
getKilometersToPixels()method 
public function getKilometersToPixels(kilometers:Number, latitude:Number):Number

Converts a value in kilometers to pixels.

Parameters
kilometers:Number — A distance in kilometers.
 
latitude:Number — The latitude in which to measure at. Defaults to the maps current center latitude.

Returns
Number
getLatLonToTileXY()method 
public function getLatLonToTileXY(latlon:LatLon):TileXY

Converts a LatLon to a TileXY object

Parameters
latlon:LatLon

Returns
TileXY

See also

LatLon
TileXY
getLatLonToXY()method 
public function getLatLonToXY(latlon:LatLon):Point

Converts a LatLon object to a point

Parameters
latlon:LatLon — A LatLon object.

Returns
Point — A Point object.

See also

LatLon
getMapBounds()method 
public function getMapBounds():BoundingBox

Retrieves the bounds of the map.

Returns
BoundingBox

See also

BoundingBox
getMetersToPixels()method 
public function getMetersToPixels(meters:Number, latitude:Number):Number

Converts a value in meters to pixels.

Parameters
meters:Number — A distance in meters.
 
latitude:Number — The latitude in which to measure at. Defaults to the maps current center latitude.

Returns
Number
getMilesToPixels()method 
public function getMilesToPixels(miles:Number, latitude:Number):Number

Converts a value in miles to pixels.

Parameters
miles:Number — A distance in miles.
 
latitude:Number — The latitude in which to measure at. Defaults to the maps current center latitude.

Returns
Number
getVersion()method 
public function getVersion():String

The current version of the API.

Returns
String
getXYToLatLon()method 
public function getXYToLatLon(point:Point):LatLon

Converts a Point to a LatLon object

Parameters
point:Point — A Point object.

Returns
LatLon — A LatLon object.
getZoomRange()method 
public function getZoomRange():Array

Returns an array of zoom levels allowed on the map base.

Returns
Array
init()method 
public function init(appid:String, width:Number, height:Number, locale:String = "en"):void

Initializes the map given a YDN application ID, width, height and locale.

Parameters
appid:String — A required application ID registered through the Yahoo! Developer Network.
 
width:Number — The initial width of the map.
 
height:Number — The initial height of the map.
 
locale:String (default = "en") — (Optional) The locale of the map.

See also

panToLatLon()method 
public function panToLatLon(latlon:LatLon, duration:Number = 250):Object

Smoothly pans the map to the specified location.

Parameters
latlon:LatLon — The latitude/longitude to pan to.
 
duration:Number (default = 250) — The time in milleseconds to pan the map.

Returns
Object — An object containing the geographic distance of the map shift, pixel delta and the point delta objects.

See also

LatLon
removeCrosshair()method 
public function removeCrosshair():void

Removes the crosshair widget from the map.

removePanControl()method 
public function removePanControl():void

Removes panning abilities from the map.

removeScaleBar()method 
public function removeScaleBar():void

Removes the ScaleBarWidget from the maps widget container

removeTypeWidget()method 
public function removeTypeWidget():void

Adds the MapTypeControl to the maps widget container

removeZoomWidget()method 
public function removeZoomWidget():void

Removes the ZoomControl from the maps widget container

setCenterAddress()method 
public function setCenterAddress(address:Address):void

Sets the map center by geocoding the address provided, and setting the maps centerLatLon when the geocoder responds.

Parameters
address:Address
setCenterByPixels()method 
public function setCenterByPixels(point:Point):void

Shifts the maps center point by the assigned delta point

Parameters
point:Point
setCenterWoeId()method 
public function setCenterWoeId(woeid:uint):void

Sets the center of the map to the provided WhereOnEarth identifier.

Parameters
woeid:uint
setHandCursor()method 
public function setHandCursor(value:Boolean):void

Sets the hand cursor visibility over the map

Parameters
value:Boolean
setMapBounds()method 
public function setMapBounds(bounds:BoundingBox):void

Sets the bounds of the map.

Parameters
bounds:BoundingBox

See also

BoundingBox
setSize()method 
public function setSize(width:Number, height:Number):void

Sets the map size.

Parameters
width:Number
 
height:Number
setZoomRange()method 
public function setZoomRange(minZoomLevel:Number, maxZoomLevel:Number):void

Sets the range of zoom levels allowed on the map base.

Parameters
minZoomLevel:Number
 
maxZoomLevel:Number
Event detail
configFailureevent 
Event object type: MapConfigEvent

Dispatched when the map configuration data fails to load or an error occured.

configSuccessevent  
Event object type: MapConfigEvent

Dispatched when the map configuration data successfully loads.

hybridTileLoadedevent  
Event object type: YahooMapEvent

Dispatched when a hybrid tile is loaded.

mapBaseCompleteevent  
Event object type: YahooMapEvent

Dispatched when the map tile engine is initialized.

mapDragevent  
Event object type: YahooMapEvent

Dispatched when the map is being dragged. Requires that the pan control is enabled.

mapDragStartevent  
Event object type: YahooMapEvent

Dispatched when the map starts dragging. Requires that the pan control is enabled.

mapDragStopevent  
Event object type: YahooMapEvent

Dispatched when the map stops dragging. Requires that the pan control is enabled.

mapInitializeevent  
Event object type: YahooMapEvent

Dispatched when the map is initialized and ready to be interacted with.

mapMouseClickevent  
Event object type: YahooMapEvent

Dispatched when the map is clicked on. Requires that the pan control is enabled.

mapMouseDoubleClickevent  
Event object type: YahooMapEvent

Dispatched when the map is double-clicked on. Requires that the pan control is enabled.

mapMouseDownevent  
Event object type: YahooMapEvent

Dispatched when the mouse is pressed over the map. Requires that the pan control is enabled.

mapMouseMoveevent  
Event object type: YahooMapEvent

Dispatched as the mouse moves over the map. Requires that the pan control is enabled.

mapMouseUpevent  
Event object type: YahooMapEvent

Dispatched when the mouse is released over the map. Requires that the pan control is enabled.

mapMoveevent  
Event object type: YahooMapEvent

Dispatched when the map is moved.

mapResizeevent  
Event object type: YahooMapEvent

Dispatched when the map is resized.

mapTileLoadedevent  
Event object type: YahooMapEvent

Dispatched when a map or satellite tile is loaded.

mapTilesLoadedevent  
Event object type: YahooMapEvent

Dispatched when all tiles have been loaded.

mapTypeChangedevent  
Event object type: YahooMapEvent

Dispatched when the current map view type has been changed.

mapZoomevent  
Event object type: YahooMapEvent

Dispatched when the maps zoom level is changed.

tileLoadErrorevent  
Event object type: YahooMapEvent

Dispatched when a tile fails to load.