V3 Version of addoverlays

251 views
Skip to first unread message

finco

unread,
Jun 18, 2010, 7:21:58 AM6/18/10
to Google Maps JavaScript API v3
Hi all,

In v2 I had a map of points that represented three related groups of
points. I presented each point with a red, blue or pruple icon
depending on the group. The points were loaded into three arrays and
each group created it's own set of markers using addoverlays. By
doing this, I was able to toggle the visibility of the whole group
without having to create and destroy the markers each time I wanted to
change their visibility.

I'm a bit puzzled how to do this in V3. Can someone point me in the
right direction as to how to create the markers once they are sitting
in my array. Previously, it might have looked like:

map.addOverlays(AllMarkers1);
AllMarkers1Visible = true;
map.addOverlays(AllMarkers2);
AllMarkers2Visible = true;
map.addOverlays(AllMarkers3);
AllMarkers3Visible = true;

where each of the AllMarkersX items held point, icon and other info.

Any help is appreciate. Thanks.

Nathan Raley

unread,
Jun 18, 2010, 9:29:35 AM6/18/10
to google-map...@googlegroups.com
I would recommend keeping what you have and instead of adding them as overlays use the marker manager.

You can push arrays of markers to the marker manager as well as remove whole arrays of markers with it as well so with what you have it would be very simple to add and/or remove markers that you have stored in arrays.

Let me know if that helps.


--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.


finco

unread,
Jun 18, 2010, 12:45:35 PM6/18/10
to Google Maps JavaScript API v3
Thanks Nathan - never used marker manager - I'll look at the
documentation and some examples.
> > To unsubscribe from this group, send email to>google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2Bunsu...@googlegroups.com>
> > .

finco

unread,
Jun 18, 2010, 8:27:00 PM6/18/10
to Google Maps JavaScript API v3
Not seeing it - anyone have an example?

Nathan Raley

unread,
Jun 21, 2010, 9:32:57 AM6/21/10
to google-map...@googlegroups.com
Not seeing what?  The documentation for MarkerManager?

To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.

finco

unread,
Jun 22, 2010, 12:23:08 PM6/22/10
to Google Maps JavaScript API v3
Sorry for being unclear - I had looked at the documentation and wasn't
"getting it". I'm there now in terms of being able to turn layers on
and off. Last step is to sync the infowindows. The correct data
appears but always attached to the last point. I think I need to
create unique markers and infowindows.

Thanks for the follow up.
> > this group, send email to>>google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2Bunsu...@googlegroups.com>> <google-maps-js-api-v3%2Bunsu...@googlegroups.com<google-maps-js-api-v3%252Buns...@googlegroups.com>

geoco...@gmail.com

unread,
Jun 22, 2010, 12:47:23 PM6/22/10
to Google Maps JavaScript API v3
On Jun 22, 9:23 am, finco <mbeck...@gmail.com> wrote:
> Sorry for being unclear - I had looked at the documentation and wasn't
> "getting it".  I'm there now in terms of being able to turn layers on
> and off.  Last step is to sync the infowindows.  The correct data
> appears but always attached to the last point.  I think I need to
> create unique markers and infowindows.

Sounds like pitfall #3 from this page of Mike Williams' v2 tutorial:
The Basics - Part 1 Markers with info windows
http://econym.org.uk/gmap/basic1.htm

are you getting function closure on your markers?

Some v3 examples here:
http://www.geocodezip.com/

-- Larry
> > > this group, send email to>>google-maps-js-a...@googlegroups.com<google-maps-js-api-v­3%2Bunsu...@googlegroups.com>> <google-maps-js-api-v3%2Bunsu...@googlegroups.com<google-maps-js-api-v3­%252Buns...@googlegroups.com>
>
> > > > > > .
> > > > > > For more options, visit this group at
> > > > > >http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Google Maps JavaScript API v3" group.
> > > To post to this group, send email to>google-map...@googlegroups.com.
> > > To unsubscribe from this group, send email to>google-maps-js-a...@googlegroups.com<google-maps-js-api-v3­%2Bunsu...@googlegroups.com>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-maps-js-api-v3?hl=en.- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages