Integrate Yahoo! maps in your Flex applications

If you want to integrate a map in your Flex application all you need to do is to go to Yahoo! Developer Network and download YahooMap-0.9.4.swc add it to your lib folder and copy/paste the code ¬†from below. You will find at Yahoo! Developer Network more, very helpful examples. Of course don’t forget to request your developer key, you will need the key to acces Yahoo! maps API.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
	creationComplete="creationCompleteHandler()">
	<mx:UIComponent id="mapContainer" width="100%" bottom="0" top="35"/>
    <mx:Script>
    	<![CDATA[
		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;
 
		import mx.events.ResizeEvent;
 
    	        protected var _yahooMap :YahooMap;
    	        protected var _address :Address;
 
 
		public function creationCompleteHandler():void
		{
			var developerKey :String = "yourDeveloperKeyHere";
 
			_yahooMap = new YahooMap();
			_yahooMap.addEventListener(YahooMapEvent.MAP_INITIALIZE, mapInitializeHandler );
			_yahooMap.init(developerKey, mapContainer.width, mapContainer.height);
 
			mapContainer.addChild( _yahooMap );
 
			//move the map with mouse
			_yahooMap.addPanControl();
			//show crosshair
			_yahooMap.addCrosshair();
 
			mapContainer.addEventListener(ResizeEvent.RESIZE, containerResizeHandler);
		}
 
		protected function containerResizeHandler( event:ResizeEvent ):void
		{
			_yahooMap.width = mapContainer.width;
			_yahooMap.height = mapContainer.height;
		}
 
		protected function mapInitializeHandler( event:YahooMapEvent ):void
		{
			_address = new Address("timisoara, romania");
			_address.addEventListener(GeocoderEvent.GEOCODER_SUCCESS, geocoderHandler);
			_address.geocode();
			trace( "map initialized" );
		}
 
		protected function geocoderHandler(event:GeocoderEvent ):void
		{
			var result :GeocoderResult = _address.geocoderResultSet.firstResult;
 
			_yahooMap.zoomLevel = result.zoomLevel;
			_yahooMap.centerLatLon = result.latlon;
		}
    	]]>
    </mx:Script>
</mx:Application>