| Package | com.yahoo.maps.webservices.geocoder.cache |
| Class | public class GeocoderCache |
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
| Property | Defined by | ||
|---|---|---|---|
| cache : Array [read-only]
The array of the GeocoderResult items currently in the cache.
| GeocoderCache | ||
| Method | Defined 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 | ||
| cache | property |
cache:Array [read-only]The array of the GeocoderResult items currently in the cache.
Implementation public function get cache():Array
| GeocoderCache | () | constructor |
public function GeocoderCache()Creates a new GeocoderCache object.
| addToCache | () | method |
public function addToCache(geocoderResult:GeocoderResult):voidAdds a GeocoderResult object to the cache.
ParametersgeocoderResult:GeocoderResult |
| getFromCache | () | method |
public function getFromCache(address:Address):GeocoderResultReturns the GeocoderCache object associated with the Address object provided, if available.
Parametersaddress:Address — An Address object.
|
GeocoderResult |
See also
| getInstance | () | method |
public static function getInstance():GeocoderCacheReturns the sole instance of this singleton class, creating it if it does not already exist.
ReturnsGeocoderCache |
| removeFromCache | () | method |
public function removeFromCache(geocoderResult:GeocoderResult):voidRemoves a GeocoderResult object from the cache.
ParametersgeocoderResult:GeocoderResult |
| resetCache | () | method |
public function resetCache():voidResets the cache.