It's a timing issue. You are calling creerMobiles() and immediately
after that you want to alert the point of the first element in your
array marqueurs, whereas in the meantime GDownloadUrl fetches the xml
and finally the markers will be pushed into the array.

You can try to put your alert in creerMobiles() just after the for
loop but inside of the callback function of GDownloadUrl

for (var i = 0; i < markers.length; i++) {
 .....
 marqueurs.push(marqueur);
 map.addOverlay(marqueurs[i]);
 }
 window.alert(marqueurs[0].getPoint());





On Jun 28, 4:40 pm, Patrice <[email protected]> wrote:
> Sorry for the indentation. It doesn't appear like that on Notepad++.
> Anyway, I am doing it from the beginning (the indentation should be
> right now). Here, I just want to display markers.
>
> http://gmapspower.free.fr/cdc_final.php
>
> The problem is that the line 38 : window.alert(marqueurs[0].getPoint
> ()); (which is there just for testing purposes) doesn't work : Firefox
> tells me that marqueurs[0] is undefined. Yet, I have put it at the
> beginning as you told me.
>
> It seems that creerMobiles doesn't modify my global array but creates
> a new one at line 54. How can I do to make it modify my array
> "marqueurs" ? It is really important because later, I would like to do
> things like marqueurs[i].setPoint(...) to move my markers.
>
> Thank you for your help !
>
> Hope that the French names for my variables don't bother any of you ^^
>
> On Jun 27, 8:57 pm, Marcelo <[email protected]> wrote:
>
> > Your arrays are not global. They are all declared inside function
> > creerCarte() and therefore they are not visible inside function
> > changerPosition().
>
> > Move the declaration to the global namespace, ie
>
> >  // CONFIGURATION INITIALE
> >           var lat = 46.41;
> >           var lng = 6.53;
> > //etc...
> > // DEFINITION DES MOBILES ET DE LEURS PARAMETRES
> >           var markers = new Array();
> > //etc ...
>
> > That'swhy proper indentation is important! ;-)
>
> > --
> > Marcelo -http://maps.forum.nu
> > --
>
> > On Jun 27, 2:41 pm, Patrice <[email protected]> wrote:
>
> > > First I'm French so it's possible that I make some English mistakes...
>
> > > I`m trying to show on map position of some cars, this positions can be
> > > changed any time, so markers have to move.
>
> > > I used to call functions that remove markers from map, and add new
> > > with new coords indefinitely. But this solution has a major drawback.
> > > It seems that old markers stay in browser memory, and after some time
> > > the memory used by the browser starts to grow 
> > > (seehttp://gmapspower.free.fr
> > > for the result (the markers don't move because the simulator is not
> > > on))
>
> > > That's why I would like to move existant markers instead of deleting
> > > them and creating new ones. But it doesn't work.
>
> > > Could you please help me ? I've been searching on the Web for weeks...
>
> > > Here's the link where you can see my problem 
> > > :http://gmapspower.free.fr/cdc.php
>
> > > This place is my last hope...
>
> > > Thank you !
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to