OK, I found this way of doing it:
var i = 0, entity;
while (i < map.entities.getLength()) {
entity = map.entities.get(i);
i += 1;
}
Question
I'm adding many polylines to my map. But after some logic I need to iterate the map.entities collection and get all my polylines.
var polylineN = new Microsoft.Maps.Polyline(loc);
// Add the pushpin
map.entities.push(polylineN);
If I iterate my map.entities I get functions, Objects, and many data. I think I need to use the map.entities.get function to retrieve the correct entities, but how will I know the index length to iterate it?
map.entities.get(0) //works fine
Something like:
_.each(map.entities, function(entity){
console.log(entity); //it returns all kind of data
});
Any help will be appreciated, any javascript iteration sample or underscore iteration sample is valid.
Solution
OK, I found this way of doing it:
var i = 0, entity;
while (i < map.entities.getLength()) {
entity = map.entities.get(i);
i += 1;
}