Thanks for your explanations, very understandable. It really helped me
but I still have a problem : now the markers are well displayed and
I've been able to display them through a GMarkerManager to determine a
minimum zoom level.
But I can't figure how to show an InfoWindow after a click event on
one marker :
I've tried this :
GEvent.addListener(vmarker, "click", function() {
for (var i=0; i<vmarkers.lenght; i++) {
vmarker.openInfoWindowHtml("Représentations
de"+vlabels[i]);
}
});
and this
GEvent.addListener(vmarker, "click", function() {
for (var i=0; i<vmarkers.lenght; i++) {
vmarkers[i].openInfoWindowHtml("Représentations
de"+vlabels[i]);
}
});
but it doesn't work :/
I try to understand and here is what I need to do :
- listen for clickevents on vmarker
- determine what vmarker it is and which vlabel to use
-show an InfoWindow with the right label on the clicked marker
What have I missed ?
Thanks again for your help.
On 24 déc, 00:49, Andrew Leach <[email protected]> wrote:
> 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.