<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="handleCreationComplete();"
viewSourceURL="srcview/index.html">
<mx:Panel title="Yahoo! Maps - Simple Flex Example" top="5" left="5" bottom="5" right="5">
<mx:UIComponent id="mapContainer" width="100%" height="100%"/>
</mx:Panel>
<mx:Script>
<![CDATA[
import mx.events.ResizeEvent;
import com.yahoo.maps.api.YahooMap;
import com.yahoo.maps.api.YahooMapEvent;
import com.yahoo.maps.api.core.location.Address;
import com.yahoo.maps.webservices.geocoder.GeocoderResult;
import com.yahoo.maps.webservices.geocoder.events.GeocoderEvent;
private var _yahooMap:YahooMap;
private var _address:Address;
private function handleCreationComplete():void
{
var appid:String = Application.application.parameters.appid;
_yahooMap = new YahooMap();
_yahooMap.addEventListener(YahooMapEvent.MAP_INITIALIZE, handleMapInitialize);
_yahooMap.init(appid,mapContainer.width,mapContainer.height);
mapContainer.addChild(_yahooMap);
mapContainer.addEventListener(ResizeEvent.RESIZE, handleContainerResize);
_yahooMap.addPanControl();
_yahooMap.addZoomWidget();
_yahooMap.addTypeWidget();
}
private function handleMapInitialize(event:YahooMapEvent):void
{
_address = new Address("141 pike st. seattle,wa");
_address.addEventListener(GeocoderEvent.GEOCODER_SUCCESS, handleGeocodeSuccess);
_address.geocode();
}
private function handleGeocodeSuccess(event:GeocoderEvent):void
{
var result:GeocoderResult = _address.geocoderResultSet.firstResult;
_yahooMap.zoomLevel = result.zoomLevel;
_yahooMap.centerLatLon = result.latlon;
}
private function handleContainerResize(event:ResizeEvent):void {
_yahooMap.setSize(mapContainer.width,mapContainer.height);
}
]]>
</mx:Script>
</mx:Application>