/*
    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
*/
package 
{
    import com.adobe.viewsource.ViewSource;
    import com.yahoo.maps.api.YahooMap;
    import com.yahoo.maps.api.YahooMapEvent;
    import com.yahoo.maps.api.core.location.LatLon;
    import com.yahoo.maps.api.overlays.PolylineOverlay;
    
    import flash.display.Sprite;

    public class YahooMap_GeodesicPolylines extends Sprite
    {
        private var _yahooMap:YahooMap;
        
        public function YahooMap_GeodesicPolylines()
        {
            ViewSource.addMenuItem(this, "srcview/index.html", true);
            
            this.stage.align = "topLeft";
            this.stage.scaleMode = "noScale";
            
            // 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 = this.loaderInfo.parameters.appid;        
            
            _yahooMap = new YahooMap();
            
            // listening for the MAP_INITIALIZE event, when it fires off, we're able to start interacting with the map.
            _yahooMap.addEventListener(YahooMapEvent.MAP_INITIALIZE, handleMapInitialize, false, 0, true);
            
            // passing our application id, width and height as parameters to initialize the map
            _yahooMap.init(appid, stage.stageWidth, stage.stageHeight);
            
            _yahooMap.addPanControl(); 
            _yahooMap.addZoomWidget(); 
            _yahooMap.addTypeWidget(); 
            
            this.addChild(_yahooMap); 
        }
        
        private function handleMapInitialize(event:YahooMapEvent):void 
        {
            _yahooMap.zoomLevel = 14; 
            _yahooMap.centerLatLon = new LatLon(45.828,-105.292); 
            
            var poly:PolylineOverlay = new PolylineOverlay(0x333333, 0.8, 5, true); // set geodesic arg to 'true' (defaults to false)
            _yahooMap.overlayManager.addOverlay(poly);

            poly.geodesicElements = 20; // sets the amount of line segments that will be used to draw the geodesic. 
            poly.dataProvider = [new LatLon(33.945500, -118.400100), new LatLon(40.644600, -73.794800), new LatLon(47.448000,-122.298000) ];
        }
    }
}