Packagecom.yahoo.maps.webservices.geocoder.cache
Classpublic class GeocoderCache

A singleton class which stores GeocoderResult objects from the geocoder.


Example
This example demonstrates how to query the cache for a GeocoderResult object based on an address.
   var addressStr:String = "Vancouver, BC";
   var cache:GeocoderCache = GeocoderCache.getInstance();
   var cachedResult:GeocoderResult = _cache.getFromCache(addressStr);
  
   if(cachedResult != null)
   {
    _map.centerLatLon = cachedResult.latlon;
   }
   else
   {
    var address:Address = new Address(addressStr);
    address.addEventListener(GeocoderEvent.GEOCODE_SUCCESS, handleGeocodeSuccess);
    address.geocode();
   }
  
   function handleGeocodeSuccess(event:GeocoderEvent):void
   {
    var result:GeocoderResult = (event.data as GeocoderResultSet).firstResult;
    _map.centerLatLon = result.latlon;
   }
  

See also

GeocoderResult


Public Properties
 PropertyDefined by
  cache : Array
[read-only] The array of the GeocoderResult items currently in the cache.
GeocoderCache
Public Methods
 MethodDefined by
  
Creates a new GeocoderCache object.
GeocoderCache
  
addToCache(geocoderResult:GeocoderResult):void
Adds a GeocoderResult object to the cache.
GeocoderCache
  
Returns the GeocoderCache object associated with the Address object provided, if available.
GeocoderCache
  
[static] Returns the sole instance of this singleton class, creating it if it does not already exist.
GeocoderCache
  
removeFromCache(geocoderResult:GeocoderResult):void
Removes a GeocoderResult object from the cache.
GeocoderCache
  
resetCache():void
Resets the cache.
GeocoderCache
Property detail
cacheproperty
cache:Array  [read-only]

The array of the GeocoderResult items currently in the cache.

Implementation
    public function get cache():Array
Constructor detail
GeocoderCache()constructor
public function GeocoderCache()

Creates a new GeocoderCache object.

Method detail
addToCache()method
public function addToCache(geocoderResult:GeocoderResult):void

Adds a GeocoderResult object to the cache.

Parameters
geocoderResult:GeocoderResult
getFromCache()method 
public function getFromCache(address:Address):GeocoderResult

Returns the GeocoderCache object associated with the Address object provided, if available.

Parameters
address:Address — An Address object.

Returns
GeocoderResult

See also

Address
getInstance()method 
public static function getInstance():GeocoderCache

Returns the sole instance of this singleton class, creating it if it does not already exist.

Returns
GeocoderCache
removeFromCache()method 
public function removeFromCache(geocoderResult:GeocoderResult):void

Removes a GeocoderResult object from the cache.

Parameters
geocoderResult:GeocoderResult
resetCache()method 
public function resetCache():void

Resets the cache.