Developer Network Home - Help

Yahoo! Maps Web Services - Flash® APIs Reference Manual

Version 3.5 - Beta Reference Manual for the Yahoo! Maps Flash APIs

This reference manual defines the classes and methods for all Flash APIs, including the JavaScript™-Flash API, ActionScript®-Flash API and Flex™ API. Unless otherwise noted, all classes and methods are available for both JavaScript and ActionScript.

Need more help? Check out our Getting Started Guides for the JS-Flash API, the AS-Flash API and the Flex API.

Classes

Class Description
EdgePan The EdgePan tool allows the user to pan the map with only mouse movement, the map pans when along the edges of the map.
CustomImageMarker Lets you add a marker with a custom image to the map surface at a specific position.
CustomPOIMarker An expandable marker that expands when the user clicks on the marker.
CustomSWFMarker Lets you load your own custom SWF marker.
CustomSWFOverlay Loads your own custom SWF overlay routines.
CustomSWFTool Loads your own custom SWF tool that can be used to manipulate the map.
EventManager [JavaScript Only] Classes that extend EventManager have the ability to dispatch custom events specified by an event type string.
GeoRSSOverlay Loads and plots a GeoRSS feed on the map.
LatLon An X-Y representation of a specific point on the map using latitude and longitude.
LatLonRect A representation of a distinct rectangle of space on a map using latitude and longitude.
LocalSearchFilter Each time a successful search is performed when using LocalSearchOverlay, 0 to n filters are returned.
LocalSearchOverlay Plots the results of text searches on the map using a large database of business descriptions, ratings, and locations.
LocalSearchResults An object representing a successful search performed using the LocalSearchOverlay
Map Instantiate a map object
Marker Instantiate a marker object
MapViews Holds static references to the three valid Map View Types
NavigatorWidget Adds a specialized navigation tool to the map.
Overlay Creates a distinct surface on top of the map that moves along with the map as it pans.
PanTool The PanTool allows the user to drag the map around for panning.
Point Lets you create a Point object which can be passed to the Map.setCenterByPointDelta() method.
PolylineOverlay An object that allows you to plot lines, curves and shapes over the map.
SatelliteControlWidget Allows the user to switch between different mapViewTypes.
SuggestedAddress Returned when a geocode error occurs. Suggested addresses can help narrow down possible values for the address that was originally entered.
Tool The parent class of various tools (such as the PanTool) that let users interact with the map.
ToolBarWidget A widget that shows all the tools that have been added to the map by using Map.addTool().
TrafficOverlay Shows the auto traffic incidents reported for the currently viewable map area.
WaypointMarker A small black marker that displays a single index.
Widget A widget represents a distinct object on the top layer of the map that usually displays information or allows users to interact with the map.

Class Details

EdgePan ()

The EdgePan tool allows the user to pan the map using the movement of the mouse. When the mouse is along the edges of the map, the map will pan in that direction. It also allows the user to double click on a position on the map and pan to that location when not along the edge.

Inherited Methods

Class Inherited Methods
Tool isInitialized
EventManager addEventListener, removeAllEventListeners, removeEventListener

Usage Example:

  import com.yahoo.maps.tools.EdgePan;

  var edgePan = new EdgePan();
  function addTool():Void {
  	myMap.addTool(edgePan, true);
  }
  

CustomImageMarker (url)

Lets you to add a custom image to the map surface at a specific position. Currently, images may only be SWF files or non-progressive JPEGs.


Constructor

Parameter Description
url The url (string) parameter specifies the URL of the image file to use for the custom marker.

Methods

Method Description
getURL()

Returns a string that is the URL of the customized marker image. This is the URL that was specified by the constructor.

Return value: string

Inherited Methods

Class Inherited Methods
EventManager addEventListener, removeAllEventListeners, removeEventListener
Marker hide, isInitialized, isVisible, show

 

CustomPOIMarker (index, title, description, markerColor, strokeColor)

An expandable marker that expands when the user clicks on the marker. When the mouse is not over the marker, only the index is shown. When rolled over, the index and title are shown. Once clicked on, the marker shows the index, title, and description.


Constructor

Parameter Description
index The index (string) is the marker's index, or label. It is usually a single character string such as "A" or "B".
title The title parameter (string) that is a title that appears when you roll the mouse cursor over the marker.
description The description (string) describes the marker when you click it. This parameter supports Flash textfield HTML formatting (a sub.
markerColor The markerColor is a hexadecimal number that specifies the marker's body color when the mouse is not over the marker. It also specifies the stroke when the marker expands to display the title or the description.
strokeColor The strokeColor (string) specifies the hexadecimal number that represents the marker's stroke color (or outline color) when the mouse is over the marker. It becomes the body color when you roll the mouse over the marker to display the title or click the marker to display the description.

Methods

Method Description
close()

Closes a marker that is expanded.

Return value: void

open()

Opens or expands the marker to the state it would be in if the user rolled over it.

Return value: void

Inherited Methods

Class Inherited Methods
EventManager addEventListener, removeAllListeners, removeEventListener
Marker hide, isInitialized, isVisible, show

Properties

Property Description
strokeColor Specifies the hexadecimal number that represents the marker's stroke (or outline) color.

Usage Example:
  import com.yahoo.maps.markers.CustomPOIMarker;

  var myMarker = {index:"Yahoo!", title:"HQ", description:"701 1st Ave, Sunnyvale, CA", markerColor:0x990099, strokeColor:0xFFFF00}};
  function addNewMarker():Void {
  	myMap.addMarkerByAddress(CustomPOIMarker, "701 1st Ave, Sunnyvale, CA", myMarker);
  }
  

CustomSWFMarker (url, ref)

The CustomSWFMarker class allows you to load a marker SWF that conforms to a specific interface. By implementing specific methods in the SWF, you can interact on a much richer level with the marker.


Constructor

Parameter Description
url The url (string) location of the SWF file.
ref A reference (number) you can pass that will be returned when the marker is created. This allows you to identify each custom SWF marker you have added.

Methods

Method Description
callCustomMethod
(methodNames, methodArgs )

Call a custom method on the SWF. If the user has implemented a custom method outside the specific interface, you can access that method by calling this.

Parameters:

  • methodNames - string, the name of the custom method.
  • methodArgs - array, an array of arguments to be passed to the custom method .

Return value: void

getURL()

Returns the URL of the image as a string

Return value: string

Inherited Methods

Class Inherited Methods
EventManager addEventListener, removeAllEventListeners, removeEventListener
Marker hide, isInitialized, isVisible, show

Usage Example:
  import com.yahoo.maps.markers.CustomSWFMarker;
  myMap.addEventListener(com.yahoo.maps.api.flash.YahooMap.EVENT_CUSTOM_MARKER_LOADED, onMarkerLoad);
  var markerURL = "marker.swf";
  var marker;
  var markerReference;
  function addNewMarker():Void {
  	myMap.addMarkerByAddress(CustomSWFMarker, "701 1st Ave, Sunnyvale, CA", {url:markerURL, ref:1} );
  }
  function onMarkerLoad(event):Void {
  	marker = event.marker;
	markerReference = event.ref;
  }
  

CustomSWFOverlay (url)

Similar to CustomSWFMarker, a custom overlay SWF component can be loaded by creating a new CustomSWFOverlay.


Constructor

Parameter Description
url The url (string) specifies the URL of the SWF file containing the custom overlay.

Methods

Method Description
callCustomMethod
(methodNames, methodArgs )

Call a custom method on the SWF. If the user has implemented a custom method outside the specific interface, you can access that method by calling this.

Parameters:

  • methodNames- string, the name of the method to call.
  • methodArgs - array, contains the arguments to pass to the custom method.

Return value: void

isLoaded()

Checks whether a custom SWF overlay has finished loading.

Return value: A Boolean value stating whether an overlay has finished loading (true) or not (false).

Inherited Methods

Class Inherited Methods
EventManager addEventListener, removeAllEventListeners, removeEventListeners
Marker hide, isInitialized, isVisible, show

Usage Example:
  import com.yahoo.maps.overlays.CustomSWFOverlay;
  myMap.addEventListener(com.yahoo.maps.api.flash.YahooMap.EVENT_CUSTOM_OVERLAY_LOADED, onOverlayLoad);
  var myOverlay = new CustomSWFOverlay("URL_TO_OVERLAY.swf");
  function addNewOverlay():Void {
  	myMap.addOverlay(myOverlay);
  }
  function onOverlayLoad(event):Void {
  	var overlay = event.overlay;
  }
  

CustomSWFTool (url, iconUrl)

A CustomSWFTool represents a SWF file that contains the proper methods for creating custom interactions with the map.


Constructor

Parameter Description
url The url (string) of the SWF that contains the tool methods.
iconUrl The iconUrl (string) specifies the URL of the image file or SWF file containing the icon that will appear in the toolbar widget.

Methods

Method Description
isLoaded()

Checks whether a custom SWF tool has finished loading.

Return value: A Boolean value stating whether a tool has finished loading (true) or not (false).

Inherited Methods

Class Inherited Methods
EventManager addEventListener, removeAllEventListeners, removeEventListeners
Tool isInitialized

Properties

Property Description
EVENT_LOADED Static property that contains the name of the loaded event

Usage Example:
  import com.yahoo.maps.tools.CustomSWFTool;
  myMap.addEventListener(com.yahoo.maps.tools.CustomSWFTool.EVENT_LOADED, onToolLoad);
  var myTool = new CustomSWFTool("URL_TO_OVERLAY.swf", "URL_TO_ICON.swf");
  function addNewTool():Void {
  	myMap.addTool(myTool);
  }
  function onToolLoad(event):Void {
  	var tool = event.tool;
  }
  

EventManager ()

Lets you listen for specified events.


Methods

Method Description
addEventListener
(eventType, functionName, scope )

Listen for an event of eventType and call the specified function in the specified scope.

Parameters:

  • eventType - string, the event type you want to listen for
  • functionName - string, the function to be called when the event occurs .
  • scope [JavaScript only] - An object that specifies the scope in which to call the listener function.

Return value: void

JavaScript only:
removeAllEventListeners()

Remove all event listeners for this object that have been subscribed by using addEventListener().

Return value: void

removeEventListener
(eventType, functionName, scope )

Removes the specified event listener for this object that have been subscribed by using addEventListener().

Parameters:

  • eventType - string, the event type which is being listened for
  • functionName - string, the listener function
  • scope [JavaScript only] - object, the scope the listener function is to be called in

Return value: void

GeoRSSOverlay (url)

The GeoRSSOverlay class allows you to load a document and plot a feed of GeoRSS items on the map.


Constructor

Parameter Description
url The url (string) specifies the URL of the RSS feed to load. The url provided must be absolute, not relative. To avoid the need for a crossdomain policy file on the server hosting the rss feed, the request is proxied through a Yahoo! server.

Inherited Methods

Class Inherited Methods
EventManager addEventListener, removeAllEventListeners, removeEventListeners
Overlay hide, isInitialized, isVisible, show

Usage Example:
  import com.yahoo.maps.overlays.GeoRSSOverlay;
  var rssOverlay = new GeoRSSOverlay("URL.xml");
  function addNewOverlay():Void {
  	myMap.addOverlay(rssOverlay);
  }
  

LatLon (latitude, longitude)

Represents a point on the map through the intersection of latitude and longitude coordinates.


Constructor

Parameter Description
latitude The latitude (float) that represents a measure of latitude, or location north or south of the equator.
longitude The longitude (float) that represents a measure of longitude, or location east or west of the prime meridian.

Properties

Parameter Description
lat A floating-point number that represents a measure of latitude, or location north or south of the equator.
lon A floating-point number that represents a measure of longitude, or location east or west of the prime meridian.

Usage Example:
  import com.yahoo.maps.LatLon;
  var latlon = new LatLon(47,-122);
  

LatLonRect (minLat, minLon, maxLat, maxLon)

A distinct rectangle of space on a map defined by two sets of latitude and longitude coordinates.


Constructor

Parameter Description
minLat A floating-point number that represents the measure of latitude on the map for the rectangle's starting point, or upper left-hand corner
minLon A floating-point number that represents the measure of longitude on the map for the rectangle's starting point, or upper left-hand corner.
maxLat A floating-point number that represents the measure of latitude on the map for the rectangle's ending point, or lower right-hand corner.
maxLon A floating-point number that represents the measure of longitude on the map for the rectangle's ending point, or lower right-hand corner.

Properties

Property Description
minLat A floating-point number that represents the measure of latitude on the map for the rectangle’s starting point, or upper left-hand corner.
minLon A floating-point number that represents the measure of longitude on the map for the rectangle’s starting point, or upper left-hand corner.
maxLat A floating-point number that represents the measure of latitude on the map for the rectangle’s ending point, or lower right-hand corner.
maxLon A floating-point number that represents the measure of longitude on the map for the rectangle’s ending point, or lower right-hand corner.

LocalSearchFilter()

Each time a successful search is performed when using the LocalSearchOverlay class, 0 to n filters are returned. Each filter represents a possible refinement of the search results. By using the key attribute of the filter, the same search terms will return refined results as described by the name attribute.


Properties

Property Description
count The number of results, out of the total search results returned, that comply with this filter.
key A string that specifies the key that needs to be passed back to LocalSearchOverlay.search() method to retrieve the refined results.
name A string that provides a readable description of the filter.
type A string that specifies the filter type, of which there are two, represented by LocalSearchFilter.TYPE_RATING and LocalSearchFilter.TYPE_CATEGORY. Rating filters allow the user to refine the search by the rating of the search results usually from one to five stars. Category filters filter by a specific category of results. For example, a search for food might return category filters with names such as "grocery", "fast food", "cafes", etc.
TYPE_CATEGORY Possible value for the LocalSearchFilter.type property. If the type property is equal to the LocalSearchFilter.TYPE_CATEGORY constant, the search() method of the LocalSearchOverlay class can use the key attribute as its categoryFilter parameter.
TYPE_RATING Possible value for the LocalSearchFilter.type property. If the type property is equal to the LocalSearchFilter.TYPE_RATING constant, the search() method of the LocalSearchOverlay class can use the key attribute as its ratingFilter parameter.

 

LocalSearchOverlay ()

The LocalSearchOverlay class allows developers to access the large database of business descriptions, ratings, and locations and plot them on a map.


Methods

Method Description
clear()

Clear the currently active search

Return value: void

search (
source, searchTerms, latlon, startIndex, results, radius, categoryFilter, ratingFilter )

Search for businesses using the specified criteria.

Parameters:

  • source - A string. Specifies which Yahoo! API to use. Available APIs are local search (local), Flickr Photos (flickr), Upcoming.org events (upcoming), Yahoo! Weather (weather), Yahoo! Traffic (traffic) and Yahoo! Travel (travel).
  • searchTerms - A string. The search terms used to search for businesses
  • latLon - The latitude and longitude of a point on the map you would like base this search on
  • startIndex - A number The index of the first result out of the total search results available that you would like to retrieve
  • results - A number. The number of results that you would like to retrieve
  • radius - A number. The radius in miles that you would like apply to search results. If null, the radius of the current viewable map is used.
  • categoryFilter - A string. The category filter key used to filter search results
  • ratingFilter - A string. The rating filter key used to filter search results
  • API Key - A string. The API key to pass when using either Flickr or Upcoming as your source. An API key is required and can be obtained for Flickr here, and for Upcoming.org here.
  • returnAsLocalSearch - A boolean. Specifies whether the overlay should plot results as regular local search results, or to simply dispatch an event with search results included. Defaults to true.

Return value: void

addLocalSearchWidget() Adds a local search widget with ready access to each Yahoo! API to the map.

Return value: void

removeLocalSearchWidget() Removes the local search widget from the map.

Return value: void

Properties

Property Description
EVENT_SEARCH_ERROR Static property that contains the name of the searchError event
EVENT_SEARCH_SUCCESS Static property that contains the name of the searchSuccess event
EVENT_API_SEARCH_SUCCESS Static property that contains the name of the apiSearchSuccess event
EVENT_WIDGET_ADDED Static property that contains the name of the widgetAdded event

Inherited Methods

Class Inherited Methods
EventManager

addEventListener, removeAllEventListeners, removeEventListener

Overlay hide, isInitialized, isVisible, show

Event Summary

Event Description
searchError This event dispatches when the search() method encounters an error. The event contains two properties.
  • source - A string which defines which API was used in the search
  • reason - A string which contains the reason why the search failed, 'noResults' or 'XMLError'.
searchSuccess This event dispatches when the search() method completes successfully. The event object contains two properties.
  • localSearchResults - A LocalSearchResults object. An instance of LocalSearchResults that contains information about the currently active search.
  • localSearchInfo - An object, contains detailed information about the active search.
apiSearchSuccess This event dispatches when the search() method completes successfully using a Yahoo! API and returnAsLocalSearch is false. The event contains two properties.
  • source - A string which defines which API was used in the search
  • results - Contains search results
widgetAdded This event dispatches when the local search widget is successfully added to the map. The event object contains a single property.
  • widget - A reference to the widget added. [AS-Flash only]

Usage Example:
  import com.yahoo.maps.overlays.LocalSearchOverlay;
  var localSearch = new LocalSearchOverlay();
  localSearch.addEventListener( com.yahoo.maps.overlays.LocalSearchOverlay.EVENT_SEARCH_SUCCESS, onLocalStatus);
  localSearch.addEventListener( com.yahoo.maps.overlays.LocalSearchOverlay.EVENT_SEARCH_ERROR, onLocalStatus);
  function addNewOverlay():Void {
  	myMap.addOverlay(localSearch);
	localSearch.search('local', 'mexican food', myMap.getCenter() );
  }
  function onLocalStatus(event):Void {
  	if (event.type == "searchError") {
		...
	}
	else if (event.type == "searchSuccess") {
		...
	}
  }
  

LocalSearchResults ()

An object representing a successful search performed using the LocalSearchOverlay


Properties

Property Description
resultsCount The number of results returned by this search.
searchFilters An array of LocalSearchFilter objects that represent possible filters that could be applied to this search.
totalResultsCount The total number of possible results that could be returned applying the current search criteria.

 

Map (container, appid, location, zoom, mapViewType)

An object that defines a map.


Constructor

Parameter Description
container The ID of the map in the HTML page, Flash document, or Flex document. For HTML, this is the usually the CSS "id" name of the tag containing the map.
appid Your Yahoo! application ID. If you don't have one, get one here.
location A LatLon object or string (address) that specifies the map’s initial position. If the string cannot be converted to a LatLon object, an EVENT_MAP_GEOCODE_ERROR event will be dispatched.
zoom The zoom level of the map -- a number between 1 and 17. The default zoom level is 14.
mapViewType The Map View Type of the map. Valid values are MapViews.SATELLITE, MapViews.HYBRID, and MapViews.MAP.

Methods

Method Description

JavaScript:
addMarkerByAddress(marker, address)

ActionScript:
addMarkerByAddress(markerClass, address, data)

Add a marker at the specified address. If the map is unable to geocode the given address, an EVENT_MARKER_GEOCODE_ERROR event will be thrown with possible address suggestions. If successful, an EVENT_MARKER_GEOCODE_SUCCESS event will be thrown.



Parameters:

  • marker - An instance of the marker to be added.
  • address - A string that specifies the postal address at which to place the marker on the map.
  • markerClass- A function that specifies the type of marker to place on the Map. This could be a reference to the CustomImageMarker class, CustomPOIMarker class, CustomSWFMarker class, or a WaypointMarker class.
  • data - [ActionScript only] An object which contains the parameters to pass to the markerClass’s constructor function.

Return value: void

JavaScript:
addMarkerByLatLon(marker, latlon)

ActionScript:
addMarkerByLatLon(markerClass, latlon, data)

Add a marker at the location specified by the latlon parameter.

Parameters:

  • marker - An instance of the marker to be added.
  • latlon - A LatLon object that specifies the latitude and longitude coordinates on the map at which to place the marker.
  • markerClass - A function that specifies the type of marker to place on the Map. This could be a reference to the CustomImageMarker class, CustomPOIMarker class, CustomSWFMarker class, WaypointMarker class, or a custom class.
  • data - [ActionScript only] An object which contains the parameters to pass to the markerClass’s constructor function.

Return value: void

addOverlay(overlay)

Add an overlay to the map. Overlays are images that are laid over the map to show driving directions, traffic conditions and so on.

Parameters:

  • overlay - An instance of an Overlay object: CustomSWFOverlay, GeoRSSOverlay, LocalSearchOverlay, or Traffic Overlay

Return value: void

addTool(tool, isActive)

Add a tool to the map.

Parameters:

  • tool - An instance of an Tool object.
  • isActive - A Boolean value stating whether the current tool is active.

Return value: void

addWidget(widget)

Add a widget to the map. Possible widget types include NavigatorWidget, ToolBarWidget and SatelliteControlWidget.

Parameters:

  • widget - An instance of an Widget object.

Return value: void

enableKeyboardShortcuts(enabled)

Enables or disables the ability to use the keyboard to pan and zoom the map. Supported keyboard shortcuts are:

  • Left Arrow key - Pan the map west.
  • Right Arrow key - Pan the map east.
  • Up Arrow key - Pan the map north.
  • Down Arrow key - Pan the map south.
  • Page Up - Zoom the map in.
  • Page Down - Zoom the map out.

Parameters:

  • enabled - A Boolean value that specifies whether the keyboard can be used to pan and zoom the map. Passing a value of false disables keyboard navigation.

Return value: void

ActionScript only:
getActiveTool()

Returns the currently active tool.

Return value: a Tool object

getAppID()

Returns a string specifying the current Yahoo! Maps application id.

Return value: a string specifying the current Yahoo! Maps application id

getBounds()

Get the LatLonRect object that specifies the current map bounds.

Return value: A LatLonRect object.

getCenter()

Get the latitude and longitude for the center point of the map.

Return value: A LatLon object.

getCurrentMapViewType()

Returns a String specifying the current Map View Type.

ActionScript only:
getHeight()

Returns the height of the map object.

ActionScript only:
getWidth()

Returns the width of the map object.

getTools()

Returns an array of instantiated tool objects.

getMapViewTypes()

Returns an array of all valid Map View Types. (“map”, “hybrid”, “satellite”)

getZoomLevel()

Gets zoom level as a number between 1 and 17.

Return value: A number from 1 to 17.

ActionScript only:
move()

Moves the Map object to the requested position.

Return value: void

removeAllMarkers()

Removes all markers from the map.

Return value: void

JavaScript only:
removeAllOverlays()

Removes all overlays from the map.

Return value: void

removeMarker(marker)

Removes the specified marker from the map.

Parameters:

  • marker - Removes the Marker object specified by tool from the map.

Return value: void

removeOverlay(overlay)

Removes the specified overlay from the map.

Parameters:

  • overlay - Removes the Overlay object specified by tool from the map.

Return value: void

removeTool(tool)

Removes the specified tool from the map.

Parameters:

  • tool - Removes the Tool object specified by tool from the map.

Return value: void

removeWidget(widget)

Removes the specified widget from the map.

Parameters:

  • widget - Removes the Widget object specified by tool from the map.

Return value: void

ActionScript only:
setActiveTool(tool)

Set the currently active tool.

Parameters:

  • tool - A Tool object to set as the active tool.

Return value: void

JavaScript only:
setAppID(appid)

Sets a new Yahoo! Maps application ID.

Parameters:

  • appid - A valid application ID.

Return value: void

setBounds(bounds)

Sets the map to the center of a rectangle specified by a LatLonRect object.

Parameters:

  • bounds - A LatLonRect object that specifies the desired bounds for the viewable map surface.

Return value: void

setCenterByAddress(address, duration)

Set the center position of the map to the specified address. If duration is greater than 0, the map will pan for the specified number of milliseconds. If the application is unable to geocode the address, it dispatches an EVENT_MAP_GEOCODE_ERROR event that contains an array of suggested addresses. If the geocode is successful, the map pans to that position and dispatches an EVENT_MAP_GEOCODE_SUCCESS event.

Parameters:

  • address - A string that specifies the street address, city, state and zip code on which to center the map.
  • duration - The number of milliseconds in which to pan (or slide) the map to the specified location. A duration of 0 represents no panning and the map moves immediately to the new location.

Return value: void

setCenterByAddressAndZoom(address, zoomLevel, duration)

Set the center position of the map to the specified address. If duration is greater than 0, the map will pan for the specified number of milliseconds. If the application is unable to geocode the address, it dispatches an EVENT_MAP_GEOCODE_ERROR event that contains an array of suggested addresses. If the geocode is successful, the map pans to that position and dispatches an EVENT_MAP_GEOCODE_SUCCESS event. The zoom levels ranges from 1 to 17, with 1 being the lowest, or closest, level and 17 being the highest, or farthest, level. If duration is greater than 0, map will pan first and then zoom.

Parameters:

  • address - A string that specifies the street address, city, state and zip code on which to center the map.
  • zoomLevel - A number from 1 to 17 that specifies the zoom level at which to view the map.
  • duration - The number of milliseconds in which to pan (or slide) the map to the specified location. A duration of null or 0 represents no panning and the map moves immediately to the new location.

Return value: void

setCenterByLatLon(latlon, duration)

Center the map on the coordinates of latitude and longitude specified by latlon. If duration is greater than 0, the map pans (or slides to the new location) for the specified number of milliseconds.

Parameters:

  • latlon - A LatLon object that specifies the desired latitude and longitude values.
  • duration - The number of milliseconds in which to pan (or slide) the map to the specified location. A duration of 0 represents no panning and the map moves immediately to the new location.

Return value: void

setCenterByLatLonAndZoom(latlon, zoomLevel, duration)

Center the map on the coordinates of latitude and longitude specified by latlon. The zoom levels ranges from 1 to 17, with 1 being the lowest, or closest, level and 17 being the highest, or farthest, level. If duration is greater than 0, map will pan first and then zoom.

Parameters:

  • latlon - A LatLon object that specifies the desired latitude and longitude values.
  • zoomLevel - A number from 1 to 17 that specifies the zoom level at which to view the map.
  • duration - The number of milliseconds in which to pan (or slide) the map to the specified location. A duration of 0 represents no panning and the map moves immediately to the new location.

Return value: void

setCenterByPointDelta(point,duration)

Set the center point of the map based on a relative number of pixels from its current location. For example, calling the setCenterByPointDelta() method and passing a Point object of (5,5) moves the map’s current coordinates left 5 pixels and up 5 pixels. Passing negative values for x and y coordinates cause the map to pan right and down.

Parameters:

  • point - A Point object
  • duration - The number of milliseconds in which to pan (or slide) the map to the specified location. A duration of 0 represents no panning and the map moves immediately to the new location.

Return value: void

setMapViewType(mapViewType)

Changes the Map View between Satellite, Hybrid, and regular Maps.

Parameters:

  • mapViewType - A string that specifies type of map that should be shown. The three valid values for this function are stored as variables of the MapViews class. Valid values are MapViews.SATELLITE, MapViews.HYBRID, and MapViews.MAP.

Return value: void

ActionScript only:
setSize(width, height)

Resizes the Map object to the requested size.

Parameters:

  • width - A number that indicates the width of the Map object, in pixels.
  • height - A number that indicates the height of the Map object, in pixels.

Return value: void

setZoomLevel(zoomLevel)

Sets the zoom level for viewing the map.

Parameters:

  • zoomLevel - A number from 1 to 17 that specifies the zoom level at which to view the map.

Return value: void

Inherited Methods

Class Inherited Methods
EventManager addEventListener, removeAllEventListeners, removeEventListener

Properties

Property Description
EVENT_CUSTOM_MARKER_LOADED Static property that contains the name of the customMarkerLoaded event.
EVENT_CUSTOM_OVERLAY_LOADED Static property that contains the name of the customOverlayLoaded event.
EVENT_INITIALIZE Static property that contains the name of the initialize event.
EVENT_MAP_GEOCODE_ERROR Static property that contains the name of the mapGeocodeError event.
EVENT_MAP_GEOCODE_SUCCESS Static property that contains the name of the mapGeocodeSuccess event.
EVENT_MAP_TYPE_CHANGED Static property that contains the name of the mapTypeChanged event.
EVENT_MARKER_GEOCODE_ERROR Static property that contains the name of the markerGeocodeError event.
EVENT_MARKER_GEOCODE_SUCCESS Static property that contains the name of the markerGeocodeSuccess event.
EVENT_MOVE Static property that contains the name of the move event.
EVENT_NAVIGATOR_STATE_CHANGED Static property that contains the name of the navigatorStateChanged event.
EVENT_ONCLICK Static property that contains the name of the onClick event.
EVENT_PAN_START Static property that contains the name of the panStart event.
EVENT_PAN_STOP Static property that contains the name of the panStop event.
EVENT_POI_CLICKED Static property that contains the name of the poiMarkerClicked event.
EVENT_SET_BOUNDS_COMPLETE Static property that contains the name of the setBoundsComplete event.
EVENT_TOOL_ADDED Static property that contains the name of the toolAdded event.
EVENT_TOOL_CHANGE Static property that contains the name of the toolChange event.
EVENT_TOOL_REMOVED Static property that contains the name of the toolRemoved event.
EVENT_ZOOM Static property that contains the name of the zoom event.
EVENT_ZOOM_STOP Static property that contains the name of the zoomStop event. (Deprecated alias is property EVENT_ZOOM_END and zoomEnd event)
EVENT_ZOOM_START Static property that contains the name of the zoomStart event

Event Summary

Event Description
customMarkerLoaded

This event dispatches when the custom SWF marker has been successfully placed and is loaded using the addMarkerByAddress() or addMarkerByLatLon() methods. The event object contains two properties:

  • marker - A Marker object which refers to the newly added marker on the map.
  • ref - A reference (number) passed when the marker was added. This allows you to identify each custom SWF marker you have added.
customOverlayLoaded

This event dispatches when the custom SWF overlay has been successfully placed and loaded using the addOverlay method. The event contains a single property.

  • overlay - A reference to the loaded overlay.
initialize

This event dispatches after the Flash SWF file that contains the map engine has loaded and is ready for interaction. The event object contains three properties:

  • center - A LatLon object which contains the center coordinates of the map.
  • bounds - A LatLonRect object which contains a distinct rectangle of space on a map defined by two sets of latitude and longitude coordinates.
  • zoomLevel - A number which contains the current zoom level the of the map.
mapGeocodeError

This event dispatches when a geocoding error occurs when you call the setCenterByAddress() method. The event object contains two properties:

  • originalAddress - A string representing the originally specified address.
  • suggestedAddresses - An array of SuggestedAddress objects that geocoding service has determined as possible alternatives to the entered address.
markerGeocodeError

This event dispatches when there has been a geocoding error when calling the addMarkerByAddress() method. The event object contains three properties:

  • hash [ActionScript only] - A string which contains a unique hash returned by the Map.addMarkerByAddress() method.
  • originalAddress - A string representing the originally specified address.
  • suggestedAddresses - An array of SuggestedAddress objects that geocoding service has determined as possible alternatives to the entered address.
markerGeocodeSuccess

This event dispatches when the marker has been successfully placed using the addMarkerByAddress() method. The event object contains two properties:

  • hash [ActionScript only] - A string which contains a unique hash returned by the Map.addMarkerByAddress() method.
  • marker - A Marker object which refers to the newly added marker on the map.
mapTypeChanged

This event dispatches when the map view type (Map, Satellite, Hybrid) has been changed. The event object contains a single property:

  • view - A string which contains the mapViewType.
move

This event dispatches whenever the map changes its latitude or longitude. The event object contains two properties:

  • center - A LatLon object which contains the center coordinates of the map.
  • bounds - A LatLonRect object which contains a distinct rectangle of space on a map defined by two sets of latitude and longitude coordinates.
navigatorStateChanged This event dispatches when the NavigatorWidget is opened or closed.
onClick

This event dispatches when the map is clicked or double-clicked. The event object contains three properties:

  • latlon - A LatLon object which contains the LatLon point of the click.
  • local - A Point object which contains the XY point of the click, relative to the map.
  • action - A string which contains the click action, singleClick or doubleClick.
panStart This event dispatches whenever the map starts to pan. Panning is initiated whenever the duration is set to be greater than 0 in the Map.setCenterByAddress(), Map.setCenterByLatLon(), or Map.setCenterByPointDelta() methods.
panStop This event dispatches when panning has stopped.
poiMarkerClicked

This event dispatches when a POI marker that has been added to the map is clicked. This event contains two properties:

  • latlon [ActionScript only] - A LatLon point of the marker..
  • marker [ActionScript only] - A reference to the marker that was added to the map
setBoundsComplete This event dispatches when the map successfully sets new bounds.
toolAdded

This event dispatches when new tool has been added to the map. The event object contains a single property:

  • tool - A reference to the tool that was added to the map.
toolChange

This event dispatches when the currently active tool has changed. The event object contains a single property:

  • tool - A reference to the tool that is currently active.
toolRemoved

This event dispatches when a tool has been removed from the map. The event object contains a single property:

  • tool - A reference to the tool that was removed from the map.
zoom

This event dispatches during when the map zooms. This event is thrown multiple times when the map zooms. The event object contains three properties:

  • currentZoomLevel - This is the current zoom level the map is scaled to.
  • startZoomLevel - The initial zoom level of the map before zooming started.
  • endZoomLevel - The target zoom level the map is scaling to.
zoomEnd

This event dispatches when the map has zoomed to the target zoom level. The event object contains two properties:

  • startZoomLevel - The initial zoom level of the map before zooming started.
  • endZoomLevel - The target zoom level the map is scaling to.
zoomStart

This event dispatches when zooming starts. The event object contains two properties:

  • startZoomLevel - The initial zoom level of the map before zooming started.
  • endZoomLevel - The target zoom level the map is scaling to.

 

MapViews ()

Holds static references to the three valid Map View Types

Properties

Property Description
SATELLITE Static property that contains the name of the "satellite" map view type.
HYBRID Static property that contains the name of the "hybrid" map view type.
MAP Static property that contains the name of the "map" map view type.

 

Usage Example:
  import com.yahoo.maps.MapViews;
  function setMapType():Void {
  	myMap.setMapViewType(MapViews.HYBRID); //CAN ALSO BE MapViews.SATELLITE or MapViews.MAP.
  }
  

Marker ()

The Marker class allows you to define map markers and toggle the visibility of markers on a map. There are several types of markers supported including: image markers ( CustomImageMarker class ), point of interest markers ( CustomPOIMarker class), SWF markers ( CustomSWFMarker class), and waypoint markers ( WaypointMarker class ).


Methods

Method Description
hide()

Hides this marker on a map.

Return value: void

isInitialized()

Returns boolean value that determines whether the object has been created.

Return value: boolean

isVisible()

Returns boolean value that indicates whether the marker is currently visible.

Return value: boolean

show()

Makes the marker visible on the map.

Return value: void

Inherited Methods

Class Inherited Methods
EventManager addEventListener, removeAllEventListeners, removeEventListener

Properties

Property Description
EVENT_INITIALIZE Static property that contains the name of the initialize event.

Event Summary

Event Description
initialize

This event dispatches when the representative Marker object has been created.

 

NavigatorWidget ()

The NavigatorWidget class lets users zoom and pan the map based on a small mini-map that appears on the map surface. NavigatorWidget instances can be added to the map using Map.addWidget()


Methods

Method Description
close()

Close the navigator widget so that only the zoom-bar appears.

Return value: void

open()

Open the navigator widget so that the mini-map appears.

Return value: void

Inherited Methods

Class Inherited Methods
Widget hide , isInitialized , isVisible , show
EventManager addEventListener, removeAllEventListeners, removeEventListener

Usage Example:
  import com.yahoo.maps.widgets.NavigatorWidget;
  myMap.addEventListener(com.yahoo.maps.api.flash.YahooMap.EVENT_NAVIGATOR_STATE_CHANGED, onNavOpenClose)
  var navigatorWidget = new NavigatorWidget("open");
  function addNavWidget():Void {
  	myMap.addWidget(navigatorWidget);
  }
  function onNavOpenClose():Void {
    ...
  }
  

Overlay ()

The Overlay class represents a distinct surface on top of the map that moves along with the map as it pans. An overlay is like a transparent layer that can contain information, such as local businesses or traffic conditions.


Methods

Method Description

ActionScript only:
addMarkerByAddress(
markerClass,
address,
data
)

Adds a Marker object at the requested address.

Parameters:

  • markerClass- A function that specifies the type of marker to place on the Map. This could be a reference to the CustomImageMarker class, CustomPOIMarker class, CustomSWFMarker class, or WaypointMarker class
  • address - A string that specifies the postal address at which to place the marker on the map.
  • data - An object which contains the parameters to pass to the markerClass’s constructor function.

Return value: a string representing the hash of the current marker.


ActionScript only:
addMarkerByLatLon(
markerClass,
latlon,
data
)

Adds a Marker object at the requested latitude/longitude.

Parameters:

  • markerClass- A function that specifies the type of marker to place on the Map. This could be a reference to the CustomImageMarker class, CustomPOIMarker class, CustomSWFMarker class, or WaypointMarker class. • latlon - A LatLon object that specifies the latitude and longitude coordinates on the map at which to place the marker.
  • latlon - A LatLon object that specifies the latitude and longitude coordinates on the map at which to place the marker.
  • data - An object which contains the parameters to pass to the markerClass’s constructor function

Return value: a string


hide()

Makes the overlay invisible.

Return value: void

isInitialized()

Returns boolean value that determines whether the overlay has been created.

Return value: boolean

isVisible()

Returns boolean value that indicates whether the overlay is currently visible.

Return value: boolean

ActionScript only:
removeAllMarkers()

Removes all markers.

Return value: void

ActionScript only:
removeMarker(
marker
)

Removes the Marker object.

Parameters:

  • marker - A Marker object

Return value: void

show()

Makes the overlay visible on the map.

Return value: void

Inherited Methods

Class Inherited Methods
EventManager addEventListener, removeAllEventListeners, removeEventListener

Properties

Property Description
EVENT_INITIALIZE A static property with the value "initialize".

Event Summary

Event Description
initialize

The event dispatches when the representative Overlay object has been created.

PanTool ()

The PanTool allows the user to drag the map around for panning. It also allows the user to double click on a position on the map and pan to that location.


Inherited Methods

Class Inherited Methods
Tool isInitialized
EventManager addEventListener, removeAllEventListeners, removeEventListener

Properties

Property Description
EVENT_DRAG_STOP A static property with the value dragStop
EVENT_DRAG_START A static property containing the name of the dragStart event.

Event Summary

Event Description
dragStart

This event dispatches when the pan tool starts dragging the map.

dragStop This event dispatches when the pan tool stops dragging the map.

Usage Example:
  import com.yahoo.maps.tools.PanTool;
  myMap.addEventListener(com.yahoo.maps.tools.PanTool.EVENT_DRAG_STOP, onPanStatus);
  myMap.addEventListener(com.yahoo.maps.tools.PanTool.EVENT_DRAG_START, onPanStatus);
  var panTool = new PanTool();
  function addNewTool():Void {
  	myMap.addTool(panTool, true);
  }
  function onPanStatus(event):Void {
    if (event.type == "dragStart") {
        ...
    }else if (event.type == "dragStop") {
        ...
    }
  }
  

SatelliteControlWidget()

The SatelliteControlWidget class allows an end user to switch between different mapViewTypes. SatelliteControlWidget instances can be added to the map using Map.addWidget()

Inherited Methods

Class Inherited Methods
Widget hide , isInitialized , isVisible , show
EventManager addEventListener, removeAllEventListeners, removeEventListener

Usage Example:
  import com.yahoo.maps.widgets.SatelliteControlWidget;
  myMap.addEventListener(com.yahoo.maps.api.flash.YahooMap.EVENT_MAP_TYPE_CHANGED, onTypeChange);
  var satControl = new SatelliteControlWidget();
  function addNewWidget():Void {
  	myMap.addWidget(satControl);
  }
  function onTypeChange(event):Void {
    var newType = event.view;
  }
  

Point (x, y)

Lets you create a Point object which can be passed to the Map.setCenterByPointDelta() method.

Constructor

Parameter Description
x The number of pixels to move the map horizontally. Passing a negative number for x causes the map to pan to the right.
y The number of pixels to move the map vertically. Passing a negative number for y causes the map to pan down.

Properties

Property Description
x The number of pixels to move the map horizontally.
y The number of pixels to move the map vertically.

PolylineOverlay ()

The PolylineOverlay class allows developers to plot points, draw lines and fill shapes on the map to create a new layer of visual location information.

Constructor

Parameters Description
url

The url (string) specifies the URL of the XML file containing the LatLon points.

[JavaScript only] - An absolute URL to the .swf file must be used.

Methods

Parameters Description
clear()

Clears the specified overlay

Return value: void

Properties

Property Description
EVENT_POLYLINE_ERROR Static property that contains the name of the overlayPolylineError event.
EVENT_POLYLINE_SUCCESS Static property that contains the name of the overlayPolylineSuccess event.

Inherited Methods

Class Inherited Methods
EventManager

addEventListener, removeAllEventListeners, removeEventListener

Overlay

hide, isInitialized, isVisible, show

Event Summary [AS & Flex APIs only]

Event Description
polylineError

This event dispatches when the plotPoints() method or validateFeed() method encounters an error.

polylineSuccess This event dispatches when the plotPoints() method completes successfully.

 

SuggestedAddress ()

Returned when a geocode error has happened, suggested addresses can help narrow down possible values for the address that was originally entered.


Methods

Method Description
toString()

Returns a properly formatted address string representing the suggested address.

Properties

Property Description
city The city for the suggested address
country The country for the suggested address
latlon The latitude and longitude for the suggested address.
state The state for the suggested address.
street The street address for the suggested address.
zip The zip for the suggested address.
zoomLevel The zoom level for the suggested address.

 

Tool ()

Tools allow the user to use the mouse to interact with the map. For example, the PanTool allows the user to pan the map by clicking and dragging the map.


Methods

Method Description
isInitialized()

A Boolean value stating whether the representative ActionScript object been created.

Return value: boolean

Inherited Methods

Class Inherited Methods
EventManager addEventListener, removeAllEventListeners, removeEventListener

Properties

Property Description
EVENT_INITIALIZE A static property containing the name of the initialize event

Event Summary

Event Description
initialize

This event dispatches when the representative Tool object has been created.

ToolBarWidget()

A widget that shows all the tools that have been added to the map by using Map.addTool() . It also allows users to select a tool and have that tool be set as the currently active tool.


Methods

Method Description
close()

Closes the toolbar

Return value: void

open()

Opens the widget so that the user can see all the possible tools.

Return value: void

Inherited Methods

Class Inherited Methods
EventManager addEventListener, removeAllEventListeners, removeEventListener
Widget hide, isInitialized, isVisible, show

 

TrafficOverlay()

Shows the traffic incidents reported for the currently viewable map area. This overlay is updated automatically whenever the map moves.


Inherited Methods

Class Inherited Methods
EventManager addEventListener, removeAllEventListeners, removeEventListener
Overlay hide, isInitialized, isVisible, show

 

WaypointMarker(waypointIndex)

A small black marker that displays a single index. Can be used for plotting distinct points on a map that need no description.


Constructor

Parameter Description
waypointIndex String that represents the current index for this waypoint.

Methods

Method Description
setWaypointIndex(waypointIndex)

Updates the index that is displayed on the marker.

Parameters:

  • waypointIndex - A string that is the desired index.

Return value: void

getWaypointIndex()

Returns the current index for this waypoint.

Return value: a string that represents the current index for this waypoint

Inherited Methods

Class Inherited Methods
EventManager addEventListener, removeAllEventListeners, removeEventListener
Marker hide, isInitialized , isVisible, show

 

Widget()

A widget represents a distinct object on the top layer of the map that usually displays information or allows users to interact with the map.


Methods

Method Description
hide()

Hide this widget

Return value: void

isInitialized()

Returns a boolean telling whether the representative ActionScript object has been created.

Return value: boolean

isVisible()

Returns a boolean telling whether the widget is visible

Return value: boolean

ActionScript only:
move(x,y)

Moves the Widget object's location to the (x,y) coordinate location .

Parameters:

  • x - A number representing the x-coordinate.
  • y - A number representing the y-coordinate.

Return value: void

show()

Make this widget visible

Return Value: void

Inherited Methods

Class Inherited Methods
EventManager addEventListener, removeAllEventListeners, removeEventListener

Properties

Property Description
EVENT_INITIALIZE A static property containing the name of the initialize event.

Attribution

For all web sites and applications that present data from the Yahoo! Maps Beta APIs, you must make attribution. Either copy one of our image banners or present the attribution text "Web Services by Yahoo!" with your web site or application.

Rate Limit

The Yahoo! Flash Maps APIs are limited to 50,000 queries per IP per day and to non-commercial use. See information on rate limiting.

Copyright © 2015 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings