Thanks, this sounds like a plan.

I'm still struggling to get my head around this though so forgive my
ignorance.

I have added setMarkers to the callback like so:

        var incidents = new Array();
        $.getJSON('http://labs.unxposed.net/democraticvoiceburma/elections/
media/json/incidents.json', function(data) {
                $.each(data.incident, function(i, incident) {
                        incidents.push([incident.Lat, incident.Lng, 
incident.Title,
incident.Type, incident.Content, incident.Location, incident.Datetime,
incident.Author, incident.Zindex]);
                });

                // Add markers to map
                setMarkers(map, incidents);

        });

Looking at the initialize function I thought that map was already
defined globally at the top of the file?

http://labs.unxposed.net/democraticvoiceburma/elections/media/js/maps.js

Thanks again.

On Oct 28, 9:07 pm, Rossko <[email protected]> wrote:
> > I'm not sure a.) I understand fully what you mean b.) If my setup
> > would allow for this
>
> You have
> $.getJSON('http://labs.unxposed.net/.... ', function(data) {
>      $.each(data.incident, function(i, incident) {
>               incidents.push([incident.Lat, ... ]);
>       });
>
> });
>
> which will build you an array of arrays of incident info ; but you
> don't do anything with it.
> The data will come asynchronously, so if you are going to do anything
> with it you must do it within the JSON callback function.
>
> To minimise any code changes you could call your setMarkers() function
> at the end of the callback, passing the JSON you have extracted.
>
> The problem is that all your functions are defined locally inside your
> initialize() function, so they won't be available when the callback is
> run some time after initialize() has completed.   Define your
> functions at the global level.

-- 
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 [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-js-api-v3?hl=en.

Reply via email to