On Dec 23, 11:15 pm, Brice <[email protected]> wrote:
> Here is the code I'm working on
> :http://boucard.brice.perso.neuf.fr/geoculture/geoloc/polytest.html
>
> I've tried to do the same with markers, modifying the code but it
> seems to be more complicated that I fisrt thought.
> I'm lost I think in the loop or maybe in the GMarker construction.
When you process your "villes" elements, you do this for each one:
var labelsvilles = villes[a].getAttribute("name");
var vpts = [];
vpts[a] = new GLatLng(...);
var vmarker = new GMarker(vpts);
vlabels.push(labelsvilles);
vmarkers.push(vmarker);
map.addOverlay(vmarker);
That is, you create a new *array* called vpts for *each* element, and
then set element a of that array to the GLatLng, and then pass the
entire array to GMarker. So for the first town, you have an array of
[GLatLng]; for the second you have an array of [undefined,GLatLng];
for the third, [undefined,undefined,GLatLng]; etc. And GMarker is
expecting a *single* GLatLng object, not an array.
If you need to keep an array of locations, then move the
var vpts = []
outside the loop, so you have a single array; then use the right
element in your marker:
var vmarker = new GMarker(vpts[a]);
There is also something wrong with the polygons: Chrome will happily
draw three polygons, but Firefox doesn't.
Andrew
--
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.