简体   繁体   中英

Bing Maps .v7 How to iterate map.entities?

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.

OK, I found this way of doing it:

                var i = 0, entity;
                while (i < map.entities.getLength()) {
                    entity = map.entities.get(i);
                    i += 1;
                }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM