Hi Levko ,
Thanks for the reply , i was not able to post the swf , i will try
that later today ..  please find my whole code below.


<?xml version="1.0" encoding="utf-8"?>
<!--
 Copyright 2008 Google Inc.
 Licensed under the Apache License, Version 2.0:
    http://www.apache.org/licenses/LICENSE-2.0
-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute" width="100%" height="100%" viewSourceURL="srcview/
index.html">
  <mx:Panel title="Google Maps API for Flash - Circle Demo"
width="100%" height="100%">
    <mx:UIComponent id="mapContainer"
        initialize="startMap(event);"
        resize="resizeMap(event)"
        width="100%" height="100%"/>
        <mx:HBox>
                 <mx:Button label="Clear" click="clearMap()"/>
     <mx:Button label="Draw Polygon" click="drawRoute()"/>

        </mx:HBox>
  </mx:Panel>
  <mx:Script>
    <![CDATA[
    import com.google.maps.overlays.PolylineOptions;
    import com.google.maps.overlays.Polyline;
        import mx.controls.Alert;
        import mx.utils.ObjectUtil;
        import com.google.maps.MapMouseEvent;
        import com.google.maps.interfaces.IProjection;
    import com.google.maps.styles.FillStyle;
    import com.google.maps.styles.StrokeStyle;
    import com.google.maps.overlays.PolygonOptions;
    import com.google.maps.overlays.Polygon;
    import com.google.maps.InfoWindowOptions;
        import flash.events.Event;
        import com.google.maps.MapEvent;
        import com.google.maps.Map;
        import com.google.maps.MapType;
        import com.google.maps.LatLng;

        private var map:Map;

        public function startMap(event:Event):void {
                map = new Map();
        map.key = "ABQIAAAA8ZrPPjIiTMDjtYWV04xD2hQz-
J5LV6rASCxLYU1xMqKNc_nHIxRZrYi7Im5aczPl8woNbIzlBFql0Q";
        map.sensor = 'false';
        map.addEventListener(MapEvent.MAP_READY, onMapReady);
        mapContainer.addChild(map);
        }

        public function resizeMap(event:Event):void {
        map.setSize(new Point(mapContainer.width, mapContainer.height));
        }

        private function onMapReady(event:MapEvent):void {
        map.setCenter(new LatLng(40.736072,-73.992062), 14,
MapType.NORMAL_MAP_TYPE);
        map.addEventListener(MapMouseEvent.CLICK, onMapClick);
                //drawCircle(53.479874, -2.246704, 10.0, 0x000080, 1, 0.75,
0x0000FF,.5);
        }
        private var pointsArray:Array = new Array();
        private var newlatlngArray:Array =  new Array();
        private function onMapClick(event:MapMouseEvent):void {
                                var latlng:LatLng = event.latLng;
                                var normalProj:IProjection =
map.getCurrentMapType().getProjection();
                var zoom:Number = map.getZoom();
                            var newPoint:Point = 
normalProj.fromLatLngToPixel(latlng,zoom);
                            pointsArray.push(newPoint);
                            newlatlngArray.push(latlng);
                            drawPolyline(newlatlngArray);
        }



        private function drawPolyline(pointsArray:Array):void{
        var polyline:Polyline = new Polyline(pointsArray, new
PolylineOptions({
            strokeStyle: new StrokeStyle({
            color: 0xFF0000,
            thickness: 2,
            alpha: 0.7})
        }));
        map.clearOverlays();
        map.addOverlay(polyline);

        }

        private function clearMap():void{
                pointsArray.length = 0;
                newlatlngArray.length = 0;
                map.clearOverlays();

        }

        private function drawRoute():void{
                var strokeColor:Number =0x000080;
                var strokeWidth:Number = 1;
                var strokeOpacity:Number = 0.75;
                var fillColor:Number = 0x0000FF;
                var fillOpacity:Number = .5;
            var polygonOptions:PolygonOptions = new PolygonOptions();
            var fillStyle:FillStyle = new FillStyle();
                fillStyle.alpha = fillOpacity;
                fillStyle.color = fillColor;
                polygonOptions.fillStyle = fillStyle;

                var strokeStyle:StrokeStyle = new StrokeStyle();
                strokeStyle.alpha = strokeOpacity;
                strokeStyle.color = strokeColor;
                strokeStyle.thickness = strokeWidth;
                        polygonOptions.strokeStyle = strokeStyle  ;

                var newpointsArray:Array = getPolygonForPath(pointsArray);
                var length:int = newpointsArray.length;
                var latlngArray:Array = new Array();
                var i:int;
                var norProj:IProjection =
map.getCurrentMapType().getProjection();

                for (i = 0; i < length-1; i++){
        
latlngArray.push(norProj.fromPixelToLatLng(newpointsArray[i],map.getZoom()));
                }
           var polygon:Polygon  = new Polygon(latlngArray,polygonOptions);
           map.addOverlay(polygon);
        }


        private function getPointFromAngle(pt:Point, radius:Number,
a:Number):Point {
        return new Point(pt.x + Math.cos(a) * radius, pt.y + Math.sin(a)
* radius);
        }

        private function getPolygonForPath(pts:Array, radius:Number =
10):Array {
        var polygon_pts:Array = [];
        var a:Number = Math.atan2(pts[0].y-pts[pts.length-1].y,
pts[0].x-pts[pts.length-1].x);
        var pa:Number = a+Math.PI/2;
        for(var i:int = 0; i < pts.length; i++) {
                if(i == 0) {
                        polygon_pts.push(getPointFromAngle(pts[i],
radius, Math.atan2(pts[i+1].y-pts[i].y,pts[i+1].x-pts[i].x) - Math.PI/
2));
                } else if(i == pts.length-1) {
                        polygon_pts.push(getPointFromAngle(pts[i],
radius, Math.atan2(pts[i-1].y-pts[i].y,pts[i-1].x-pts[i].x) + Math.PI/
2));
                } else {
                        polygon_pts.push(getPointFromAngle(pts[i],
radius, pa));
                }
        }
        for(i = pts.length-1; i >=0 ; i--) {
                if(i == 0) {
                        polygon_pts.push(getPointFromAngle(pts[i], -
radius, Math.atan2(pts[i+1].y-pts[i].y,pts[i+1].x-pts[i].x) - Math.PI/
2));
                } else if(i == pts.length-1) {
                        polygon_pts.push(getPointFromAngle(pts[i], -
radius, Math.atan2(pts[i-1].y-pts[i].y,pts[i-1].x-pts[i].x) + Math.PI/
2));
                } else {
                        polygon_pts.push(getPointFromAngle(pts[i], -
radius, pa));
                }
        }
        polygon_pts.push(polygon_pts[0]);
        return polygon_pts;
        }

    ]]>
  </mx:Script>
</mx:Application>


thanks
Kannan.

On May 23, 10:26 am, Levko Yaskewych <[email protected]> wrote:
> trace a url and post it so the formation can be assessed then your code will
> be quick to fix
>
>
>
>
>
>
>
> On Sun, May 22, 2011 at 2:11 AM, prathosh <[email protected]> wrote:
> > Hi All,
>
> > I need to draw a Polygon Overlay around my route points with a
> > specified width , i found a similar post here
>
> >http://groups.google.com/group/google-maps-api-for-flash/browse_threa...
>
> > i tried the below code, but if the route points are more than two the
> > polygon is not properly drawn always ,the polygon tapers at some
> > points , there is some issue which i was not able to figure out  can
> > anyone please help me to solve this issue .
>
> >        private function drawRoute():void{
> >                var strokeColor:Number =0x000080;
> >                var strokeWidth:Number = 1;
> >                var strokeOpacity:Number = 0.75;
> >                var fillColor:Number = 0x0000FF;
> >                var fillOpacity:Number = .5;
> >            var polygonOptions:PolygonOptions = new PolygonOptions();
> >            var fillStyle:FillStyle = new FillStyle();
> >                fillStyle.alpha = fillOpacity;
> >                fillStyle.color = fillColor;
> >                polygonOptions.fillStyle = fillStyle;
>
> >                var strokeStyle:StrokeStyle = new StrokeStyle();
> >                strokeStyle.alpha = strokeOpacity;
> >                strokeStyle.color = strokeColor;
> >                strokeStyle.thickness = strokeWidth;
> >                        polygonOptions.strokeStyle = strokeStyle  ;
>
> >                var newpointsArray:Array = getPolygonForPath(pointsArray);
> >                var length:int = newpointsArray.length;
> >                var latlngArray:Array = new Array();
> >                var i:int;
> >                var norProj:IProjection =
> > map.getCurrentMapType().getProjection();
>
> >                for (i = 0; i < length-1; i++){
>
> > latlngArray.push(norProj.fromPixelToLatLng(newpointsArray[i],map.getZoom()) 
> > );
> >                }
> >           var polygon:Polygon  = new Polygon(latlngArray,polygonOptions);
> >           map.addOverlay(polygon);
> >        }
>
> >        private function getPointFromAngle(pt:Point, radius:Number,
> > a:Number):Point {
> >        return new Point(pt.x + Math.cos(a) * radius, pt.y + Math.sin(a)
> > * radius);
> >        }
>
> >        private function getPolygonForPath(pts:Array, radius:Number =
> > 10):Array {
> >        var polygon_pts:Array = [];
> >        var a:Number = Math.atan2(pts[0].y-pts[pts.length-1].y,
> > pts[0].x-pts[pts.length-1].x);
> >        var pa:Number = a+Math.PI/2;
> >        for(var i:int = 0; i < pts.length; i++) {
> >                if(i == 0) {
> >                        polygon_pts.push(getPointFromAngle(pts[i],
> > radius, Math.atan2(pts[i+1].y-pts[i].y,pts[i+1].x-pts[i].x) - Math.PI/
> > 2));
> >                } else if(i == pts.length-1) {
> >                        polygon_pts.push(getPointFromAngle(pts[i],
> > radius, Math.atan2(pts[i-1].y-pts[i].y,pts[i-1].x-pts[i].x) + Math.PI/
> > 2));
> >                } else {
> >                        polygon_pts.push(getPointFromAngle(pts[i],
> > radius, pa));
> >                }
> >        }
> >        for(i = pts.length-1; i >=0 ; i--) {
> >                if(i == 0) {
> >                        polygon_pts.push(getPointFromAngle(pts[i], -
> > radius, Math.atan2(pts[i+1].y-pts[i].y,pts[i+1].x-pts[i].x) - Math.PI/
> > 2));
> >                } else if(i == pts.length-1) {
> >                        polygon_pts.push(getPointFromAngle(pts[i], -
> > radius, Math.atan2(pts[i-1].y-pts[i].y,pts[i-1].x-pts[i].x) + Math.PI/
> > 2));
> >                } else {
> >                        polygon_pts.push(getPointFromAngle(pts[i], -
> > radius, pa));
> >                }
> >        }
> >        polygon_pts.push(polygon_pts[0]);
> >        return polygon_pts;
> >        }
>
> > thanks and regards
> > Prathosh
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Maps API For Flash" group.
> > To post to this group, send email to
> > [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> >http://groups.google.com/group/google-maps-api-for-flash?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API For Flash" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-api-for-flash?hl=en.

Reply via email to