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_thread/thread/272c7c1f41eb9d4c/d75ea062fc71c682?lnk=gst&q=route+#d75ea062fc71c682 > > 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.
