Hi Sylvain, The approach looks good. I'll try to get some reference code posted here soon. We've got an example for the JS Maps API and we'll prepare one for the Maps API for Flash.
One suggestion is to test that you have got a 620 response code before resending requests with exponential back-off. Without that an un- parseable request would block the queue. I'll reply to this thread once any example code is prepared. Thanks, Mike On Aug 12, 3:21 am, Sylvain <[email protected]> wrote: > Hi, > > I'm beginning with the google map api for Flash and what I'd like to > do is : > > - Open an XML file and gather numerous addresses say : A, B, C, D. > - Construct the paths between these addresses namely, A-B, B-C, C-D. > - Calculate the directions corresponding to these paths. > - Display all the directions polyline on my map. > > In flash, I have a loop made of a timer to execute the following > code : > > function onloadDirectionTimer(event:TimerEvent):void > { > //Stop the timer to have 1 request at a time > loadDirection.stop(); > > //Define the path > path = str_place[i] + " to " + str_place[i+1]; > > //Calcul de la direction > var dir:Directions = new Directions(); > dir.addEventListener(DirectionsEvent.DIRECTIONS_SUCCESS, > onDirLoadInitial); > dir.addEventListener(DirectionsEvent.DIRECTIONS_FAILURE, > onDirFail); > dir.load(path); > } > > function onDirLoadInitial(event:DirectionsEvent):void { > > var dir:Directions = event.directions; > var route:IPolyline; > > route=dir.createPolyline(); > > map.addOverlay(route); > > i++ > //Direction calculated, start the timer for the next > direction > loadDirection.start(); > } > > function onDirFail(event:DirectionsEvent):void { > trace("Status:" + event.directions.status); > i++; > loadDirection.start(); > } > > Sometimes, I'm getting the status 620, sometimes I don't...and when I > do, there is no way of getting the direction calculated : > > - I've tried to set a higher delay : doesn't seem to rely on this. > - I've tried to send the request again, and exponentially by doing > this : > > function onDirFail(event:DirectionsEvent):void { > trace("Status:" + event.directions.status); > //add 1 to the number of time the Timer is executed > loadDirection.repeatCount = loadDirection.repeatCount+1 > //don't increase i so that the same step is sent to > the Direction request > //i++ > //increase the delay by 2 each time > loadDirection.delay=temp_delay*2; > loadDirection.start(); > } > > If a failure occurs, the delay is doubled again and again. If a > success occurs, temp_delay is set to the initial one. > This doesn't work as well : when there is a 620 status it's like I > can't get over it even if I send the request again with a bigger > delay. It will always be a FAILURE. > > So finally, I don't loop if I've got a FAILURE because it seems > worthless. I just use the first method I described and if an error > occurs nothing is displayed. > > Do you have any clue about how to get this thing working properly ? > That is : if a FAILURE happens, sending again the request and > eventually getting a SUCCESS ? > > Thank you very much ! > > P.S : I'm not even close of the 15000 requests per day allowed. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
