Yes, thanks those two were definately issues.
For now I've just changed it to return strings instead of variables
for all but lat lng and title:
var incidents = new Array();
$.getJSON('http://labs.unxposed.net/democraticvoiceburma/elections/
media/json/incidents.json', function(data) {
$.each(data.incident, function(i, incident) {
//alert(incident.Title);
incidents.push([incident.Lat, incident.Lng,
incident.Title,
"violence", "Content", "Location", "Date", "Author", 1000]);
});
// Add markers to map
setMarkers(map, incidents);
});
I'm now getting (in chrome) one marker appear (but on page refresh it
dissapears - only works first time opened in new tab - weird?) - which
appears to come from around the middle of the json object. If I
uncomment alert(incident.Title); it does return all incident reports -
so the each lopp is working.
At least I'm making some sort of progress!
Thanks for your help.
On Oct 29, 8:15 am, JoshN <[email protected]> wrote:
> I found two problems, but the first is probably your issue.
>
> 1. getMarkerImage('violence') causes an error. I'd use:
> if(!icons.type)
> icons.type = new google.maps.MarkerImage(//your code)
> //etcetera.
> I always have trouble with associative arrays in js.
>
> 2. countryBurma is undefined, since your polygon is commented out. I'd
> comment out coordinates[0] = ...
>
> Sorry, I'm not very good with jQuery, but I think the icons are your
> issue.
>
> Best,
> JN
>
> On Oct 28, 11:30 pm, unxposed <[email protected]> wrote:
>
>
>
> > 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.