I'm struggling with the syntax when trying to create an array of objects.
I have a JSON feed which has a boat load of data in a don't need so I'm
just grabbing the relevant values and creating a new array (it's to be
using in a leaflet.js map btw)
The format I need is:
markers: {
marker-name-1:{"lat":32.0852999,"lng":34.7817676},
marker-name-2:{"lat":30.0444196,"lng":31.2357116}
}
Using:
feed = Datafeed.query(function (response){
_.each(response, function(rows) {
var latstr = rows.custom_fields._wp_geo_latitude;
var lngstr = rows.custom_fields._wp_geo_longitude;
var title = rows.title;
var result = {title : {lat : latstr , lng : lngstr}};
newArray.push(result);
});
});
I get:
{"title":{"lat":"32.0852999","lng":"34.7817676"}},
{"title":{"lat":"30.0444196","lng":"31.2357116"}}
Which won't work dammit! The title variable is ignored to as it's assuming
that's the key name I want.
Some help on how I can construct what I'm after would be much appreciated.
Thanks
Antony
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.