This routine (see below) seems to work well for a 'directions'
polyline with a high vertex count but seems to break with a simple
poly line with 2. Am I doing something wrong? Thanks

// Get the point X metres along the polyline, updating the step
description
                private function getPointAtDistance(metres:Number):LatLng {

                if (metres == 0) return polyline.getVertex(0);
                if (metres < 0) return null;
                var dist:Number=0;
                var olddist:Number=0;
                for (var i:uint=1; (i < polyline.getVertexCount() && dist <
metres); i++) {
                        olddist = dist;
                        dist += 
polyline.getVertex(i).distanceFrom(polyline.getVertex
(i-1));
                }
                if (dist < metres) {return null;}
                        var p1:LatLng= polyline.getVertex(i-2);
                        var p2:LatLng= polyline.getVertex(i-1);
                        var m:Number = (metres-olddist)/(dist-olddist);

                 // Use linear interpolation on the last bit
                return new LatLng(p1.lat() + (p2.lat()-p1.lat())*m,
                    p1.lng() + (p2.lng()-p1.lng())*m);
                }

On Nov 18, 5:55 pm, "pamela (Google Employee)" <[EMAIL PROTECTED]>
wrote:
> Hi bizpo-
>
> I believe that Mike William's EPoly extension for the JS API has a function
> that will calculate this for you - GetPointAtDistance. You can convert this
> function into AS3 for your own use. It may only work for non-geodesic
> polylines, however; I haven't tested that myself. Here's the page for the
> extension:http://econym.googlepages.com/epoly.htm
>
> - pamela
>
> On Wed, Nov 19, 2008 at 9:48 AM, bizpo <[EMAIL PROTECTED]> wrote:
>
> > How does one calculate the LatLng of points along a geodesic Polyline
> > connecting two points. I'd like to move a marker along this smooth
> > line that follows the curve of the earth. If that is not possible -
> > how could you calculate it along a straight line connecting two
> > points. Thank You.
--~--~---------~--~----~------------~-------~--~----~
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