Or instead of looping through all your markers each time one is made
visible to hide all the others, you could keep a reference to the last
marker that was made visible.

When another marker is clicked on hide that last marker, show the
clicked on marker and then keep a reference to that clicked marker.

If you have a large number of markers it'd be more efficient than
looping through the markers on every marker click.

Martin.


On Feb 19, 4:50 am, xelawho <[email protected]> wrote:
> > What a nice map you have -http://www.xelawho.com/map/!
>
> why, thank you Irahim. That's very nice of you to say so. I have tried
> the patience of every regular on this forum getting it the way it is,
> but I'm happy with it.
>
> > I noticed you show one marker at a time, but couldn't figure it from
> > your extensive code...
>
> my markers are stored in an xml file that you can see 
> here:http://xelawho.com/map/categories2.xml
>
> and then shown and manipulated using the javascript. I used a very
> similar page to this one:http://econym.org.uk/gmap/example_map3.htm
>
> when I started out and built it from there.
>
> Once you have that in place, it's a simple matter of looping though
> the markers in your xml file and hiding them once a new click is
> registered, so that modified function would look like this:
>
> function createMarker(point,name,html) {
>         var marker = new GMarker(point);
>         GEvent.addListener(marker, "click", function() {
>          for (var g = 0; g < gmarkers.length; g++) {
>                   gmarkers[g].hide();
>         }
> marker.openInfoWindowHtml(html);
>         });
>
> I think... give it a try, anyway.
>
> I understand that you don't need to put your markers in an xml file to
> loop through them like that, but following the examples on that site
> as closely as possible helped me immensely, particularly when I was
> starting out, and all (or most) of the more advanced tutorials there
> assume that you have your markers stored in an external file.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API V2" 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