<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (c) 2008 Yahoo! Inc.  All rights reserved.  
    The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license
-->
<mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml" 
    layout="absolute" 
    creationComplete="onCreationComplete(event)" 
    viewSourceURL="srcview/index.html">
    
    <mx:UIComponent id="mapContainer" width="100%" height="100%"/>
    <mx:Script>
        <![CDATA[
            import mx.effects.Resize;
            import mx.events.ResizeEvent;
            import com.yahoo.maps.api.overlays.PolylineOverlay;
            import com.yahoo.maps.api.core.location.LatLon;
            import com.yahoo.maps.api.YahooMapEvent;
            import com.yahoo.maps.api.YahooMap;
            
            private var _yahooMap:YahooMap;
            private var _polyline:PolylineOverlay;
        
            private function onCreationComplete(event:Event):void 
            {
                // this examples uses an application id passed into the app via FlashVars.
                // Get your own from the Yahoo! Developer Network @ http://developer.yahoo.com/wsregapp/
                var appid:String = Application.application.parameters.appid;
                
                // create YahooMap instance and listen for map initialize event
                _yahooMap = new YahooMap(); 
                _yahooMap.addEventListener(YahooMapEvent.MAP_INITIALIZE, handleMapInitialize); 
                _yahooMap.init(appid, mapContainer.width, mapContainer.height);
                
                mapContainer.addEventListener(ResizeEvent.RESIZE, handleResize);
                mapContainer.addChild(_yahooMap);    
            }
            
            private function handleResize(event:ResizeEvent):void 
            {
                _yahooMap.setSize(mapContainer.width,mapContainer.height);
            }
            
            private function handleMapInitialize(event:YahooMapEvent):void 
            {
                _yahooMap.zoomLevel = 14;
                _yahooMap.centerLatLon = new LatLon(39.23225,-99.84375);
                
                _yahooMap.addPanControl();
                _yahooMap.addZoomWidget();
                _yahooMap.addTypeWidget();
                
                _polyline = new PolylineOverlay(0xFF0000, 0.85, 4);
                _yahooMap.overlayManager.addOverlay(_polyline);
                
                // disable the mouse so we can still click and drag the map when the mouse is over the polyline
                _polyline.mouseEnabled=false;
                
                // set the fill color and fill alpha of the overlay
                _polyline.hasFill = true;
                _polyline.fillColor = 0xFFFFFF;
                _polyline.fillAlpha = 0.60;
                
                // pass latlon values into the polyline data provider to draw the overlay. 
                _polyline.dataProvider = [new LatLon(47.610015,-122.187029), new LatLon(37.371612,-122.038258), new LatLon(40.714550,-74.007124)];
            }
            
        ]]>
    </mx:Script>
</mx:Application>