Hi Larry, I have I clue, at the beginning of the callback routine I
included
if (status == google.maps.ElevationStatus.OK)
{
document.getElementById("elvolumen").value= "OKKK";
}
else
{
document.getElementById("elvolumen").value= "BADDD";
}
When I use few or none pauses, it sets elvolumen with a value of
BADDD, do you know why is this condition?
I tried to put a return, but the program simply stops processing
anyway.
thanks Larry,
mariobi40
On 9 jun, 17:51, "[email protected]" <[email protected]> wrote:
> On Jun 9, 3:40 pm, mariovi <[email protected]> wrote:
>
>
>
>
>
> > Hi Larry, I solved it by testing different options, so I dont know why
> > it works,
> > In the else part I include the following PAUSES:
> > else
> > //test end of tasks and exit if reach end
> > //prepares segment to get elevations from
> > rx=1;
> > pause(); //new
> > pause(); //new
> > pause(); //new
> > //call evelation service....getElevationAlongPath...,
> > calculateVolumen)
>
> > where pause has:
> > function pause()
> > {
> > var jjn;
> > jjn=0;
> > while (jjn <= 2000)
> > {
> > var jjm;
> > jjm=0;
> > while (jjm <= 4000)
> > jjm++;
> > jjn++;
> > }
> > }
> > if I put only two pauses, doesnt work, maybe you or another expert can
> > explain why it works this way
>
> Looks like you are just waiting until the response comes back from the
> server, a fixed delay is not a robust solution as network delays are
> variable.
>
> The correct solution is to use the call back function, it runs when
> the data is available, that is why asynchronous services have them.
>
>
>
> > greetings and I really appreciate your help
> > mariobi40
>
> > On 9 jun, 14:21, "[email protected]" <[email protected]> wrote:
>
> > > On Jun 9, 11:11 am, mariovi <[email protected]> wrote:
>
> > > > Hi Larry, the callback routine is calculateVolumen, and the alert is
> > > > inside this routine. I tried to follow the execution by printing
> > > > alerts like "rx=0", "rx=1", at the beginning of the IF and ELSE, so
> > > > when the program runs ok, it prints rx=0, rx=1,rx=0, rx=1,rx=0, rx=1
> > > > etc, etc
> > > > somehow, it prints rx=0, rx=1, rx=1, and at this point is when the
> > > > failure occurs, but I dont see how this could have happended. Can you
> > > > see?
>
> > > > My code is my pc, inside my company, how can I share it to you?
>
> > > As the terms of use require it to be public eventually, you could put
> > > in on the public server where it will eventually be (if it won't ever
> > > be public, you have a Premier license and you could try your Google
> > > rep). Or you could find a free host (that works with google maps) and
> > > post it there.
>
> > > -- Larry
>
> > > > greetings
> > > > mariobi40
>
> > > > On 9 jun, 11:40, "[email protected]" <[email protected]> wrote:
>
> > > > > On Jun 9, 9:27 am, mariovi <[email protected]> wrote:
>
> > > > > > Hi, I have the following resumed code
>
> > > > > > main
> > > > > > stuff...
> > > > > > rx=0;
> > > > > > calculateVolumen()
>
> > > > > > function calculateVolumen(results, status)
> > > > > > if (rx==1)
> > > > > > //process results
> > > > > > alert(results.length); //creates a pause
> > > > > > rx=0;
> > > > > > jj++; // go to next task
> > > > > > calculateVolumen()
> > > > > > else //means rx==0
> > > > > > //test end of tasks and exit if reach end
> > > > > > //prepares segment to get elevations from
> > > > > > rx=1;
> > > > > > //call evelation service....getElevationAlongPath...,
> > > > > > calculateVolumen)
>
> > > > > > if I comment the alert, the programs fails, sending that
> > > > > > results.length is null or is not an object. With the alert, program
> > > > > > run nicely as long as I dont press fast the alert, if I press
> > > > > > repeatedly fast the alert, also fails.
> > > > > > I need the program to behave wihout pauses, can you explain this
> > > > > > behavior? or how to fix it?
> > > > > > As you can see, the programa alternates execution between the true
> > > > > > and
> > > > > > false secctions of the IF.
>
> > > > > I can't see that from a code dump. If you provided a link to your map,
> > > > > I might be able to.
>
> > > > > > thanks a lot friends
> > > > > > mariobi40
>
> > > > > The elevation service is asynchronous. Usually if it works with an
> > > > > alert but doesn't work without it, it means you are trying to use the
> > > > > results outside of the callback routine.
>
> > > > > -- Larry- Ocultar texto de la cita -
>
> > > > > - Mostrar texto de la cita -- Ocultar texto de la cita -
>
> > > - Mostrar texto de la cita -- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" 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-js-api-v3?hl=en.