none
Bing Microsoft.Maps.Layer.add function bug RRS feed

  • Question


  • I am experiencing something similar to this problem: https://social.msdn.microsoft.com/Forums/en-US/254c8923-bddd-4ca7-9e52-8b8125ddf018/it-seems-to-have-bug-in-add-method-of-a-layer-at-0-indexbing-map-v8?forum=bingmapsajax

    When I try to display a pushpin on top of other pushpins in a layer by removing it from the layer and adding it back in at index 0, the the removed/re-inserted pushpin ends up at the end of the list of pushpins, and thus, at the bottom of stack, visually, due to the way that the pushpins are rendered on the Canvas element.

    I reproduced this behavior in the Bing Maps V8 interactive SDK page with the Branch set to Release using this code:

    var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {});

    var center = map.getCenter();
    var center_offset_by_a_bit = center.clone();
    center_offset_by_a_bit.longitude += 0.005;
    var red_pushpin = new Microsoft.Maps.Pushpin(center, { color: 'red' });
    var blue_pushpin = new Microsoft.Maps.Pushpin(center_offset_by_a_bit, { color: 'blue' });
    var layer = new Microsoft.Maps.Layer();
    layer.add(red_pushpin);
    layer.add(blue_pushpin);
    map.layers.insert(layer);
    document.getElementById('printoutPanel').innerHTML =
        'Red on top of blue<br>swapping red and blue in 2 seconds...';
    setTimeout(function() {
    layer.remove(blue_pushpin);
    layer.add(blue_pushpin, 0);
    document.getElementById('printoutPanel').innerHTML +=
    '<br>Should be blue on top of red now. Is it?';
    }, 2000);

    What am I doing wrong here?
    Thursday, February 15, 2018 5:01 PM

Answers

All replies