0

I am loading a bings(Microsoft) map through external source i.e., I am not creating the map. I want to change the color of pushpin which is already added to the map. When I use the following code:

var map = new Microsoft.Maps.Map(document.getElementById('map'), {});
var updatePrintout = setTimeout(function () {
    for (var i = map.entities.getLength() - 1; i >= 0; i--) {
        var pushpin = map.entities.get(i);
        if (pushpin instanceof Microsoft.Maps.Pushpin) {
            map.entities.removeAt(i);
                      pushpin.setOptions({ color:'aqua' });
                      map.entities.push(pushpin);
        }}
}, 2000);

It resets(clears all the pushpins) the map which i don't want. Is there a way to change the color of pushpin of existing map such as obtaining reference of existing map.

pebble
  • 331
  • 2
  • 13

1 Answers1

0

Don't remove/add the pushpin. There is no need for that and that will only cause issues.

map.entities is a deprecated feature for a couple years now. Use a layer instead for better performance.

rbrundritt
  • 16,570
  • 2
  • 21
  • 46