On Apr 14, 4:56 pm, "i...@noozealand.co.nz" <i...@noozealand.co.nz>
wrote:
> Hi Larry,
>
> Ok, getting there.... so I've now got the Map coming up with a global
> declaration.
>
> If I put the loop inside the XMLCallback, then yes, I get my markers.
> However, I want to be able to access these markers AFTER the load
> event (i.e. I want to be able to turn them on and off by capturing
> Javascript events). Essentially, I'm trying to replicate the
> functionality of the TripAdvisor maps, where you can turn certain
> markers on and off dynamically by choosing check boxes.
>
> So I guess the question is.... How do I get my Array of Markers to
> persist as a Global Array of Marker Objects?

Last I looked at your code it was global (I didn't look again).

>
> Am I doing this the right way, or should I be loading arrays of
> Markers using Ajax based on events? I was hoping to load in ALL of my
> markers (there will be around 1000 total) and then turn them on/off by
> iterating through the array of object markers dynamically.
>
> Is this logical?

There probably isn't a "right way", there are lots of trade offs that
can be made if you need to display lots of locations.  How you
implement it will also depend on your skill set and what you have
available on your server.  It can be made to work this way, whether it
performs well enough is your decision.  1000 markers displayed at the
same time will effect the browser performance (particularly in IE).
And loading and displaying 1000 markers will delay initial page load,
but only you can determine if it meets your needs.

Have you seen Mike Williams' marker "categories" page in his tutorial?
Part 25 Marker Categories
http://econym.org.uk/gmap/categories.htm

   -- Larry

>
> Cheers,
> Todd
>
> On Apr 15, 3:48 am, "geocode...@gmail.com" <geocode...@gmail.com>
> wrote:
>
>
>
> > On Apr 14, 7:36 am, Andrew Leach <andrew.leac...@googlemail.com>
> > wrote:
>
> > > On Apr 14, 3:23 pm, "i...@noozealand.co.nz" <i...@noozealand.co.nz>
> > > wrote:
>
> > > > oops... and the code is running atwww.winemap.co.nz(veryrawand
> > > > dirty).
>
> > > The problem is that at the time the browser reaches the line
> > >   var map = new GMap2(document.getElementById("map"));
> > > it still doesn't know anything about your div called "map"; so you are
> > > effectively doing
> > >   var map = new GMap2(null);
> > > and that won't work.
>
> > > The correct way of doing this is to define the variable in global
> > > scope:
> > >   var map;
> > > and then assign a value that global variable when you need to:
> > >   map = new GMap2(...)
>
> > > Because the variable is global, that value is available throughout the
> > > script.
>
> > You also have your "for (var j = 0; j < xmlLoadedMarkers.length; j++)
> > {" loop outside of the callback function, so when it executes the
> > array is empty.  Move it to the end of the callback function.
>
> >   -- Larry- Hide quoted text -
>
> - Show quoted text -

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

Reply via email to