And apparently GDirections is a dynamic class which allows me to add
properties to it like this:
for(r=0; r<activeRides.length; r++)
{
rides[r] = new GDirections(map);
rides[r].my_r = r;
...
GEvent.addListener(rides[r], "load", function (e)
{
alert("my r = " + this.my_r); //<<<-------- alerts the
value of r correctly !!!
alert(this.getDistance().meters);
}
);
}
I can still use help with questions 1 and 3 , though.
Best regards,
Marv
On Oct 8, 11:56 am, marvelade <[EMAIL PROTECTED]> wrote:
> I think I found an answer to Q2 myself, using a function literal
> within the addEventListener:
>
> inside the function I can apparently use "this" to rever to the
> GDirections object
>
> GEvent.addListener(rides[r], "load", function (e)
> {
>
> alert(this.getDistance().meters);
> }
> );
>
> Is this the correct way or am I cutting corners here?
>
> All comment is welcome.
>
> Beste regards,
> MArve
>
> On Oct 8, 11:25 am, marvelade <[EMAIL PROTECTED]> wrote:
>
> > Hi all,
>
> > Please take a look at this GM-app:
>
> >http://www.marvelade.com/projects/ride_on_off/index.html
>
> > I have 3 questions about this:
>
> > Q1: I need to put my own markers in, which I did using GIcon objects
> > and adding them as overlays. To get rid of the default icons, I had to
> > do this:
>
> > G_START_ICON.image = "./doesntexist.png";
> > G_END_ICON.image = "./doesntexisteither.png";
>
> > but some browsers display a questionmark there because they didn't
> > find the files (obviously)
>
> > I can't redefine G_START_ICON and G_END_ICON to accommodate the change
> > in the different rides, because they are apparently global icons for
> > all itineraries; I need them to be different for each ride.
>
> > How do I solve this?
>
> > Q2: since I work with an array of GDirections objects, I need to
> > reference them with rides[r] within a for-loop.
>
> > How do i pass this one on to the load-event-handler, since r is a
> > local variable to the for-loop?
>
> > Q3: I want to adjust the color of the polyline as well, but I haven't
> > found a way to do this. I've read in some posts to draw the polyline
> > manually, but as I can't get the lode-event-handler set up properly, I
> > haven't begun investigating this. If anyone can post a good example
> > for getting the waypoints out of a GDirections object and mapping them
> > into a custom-colored polyline, pI'd be very grateful.
>
> > Best regards and thanks to anyone who can enlighten this subject,
> > Marvelade
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" 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?hl=en
-~----------~----~----~----~------~----~------~--~---