locked
Bing Maps V8 Primitive Visibility Bug RRS feed

  • Question

  • When changing the visibility of a primitive in a layer to 'false', the primitive is actually removed entirely from the layer and cannot then be set to be visible again. Viewing the array returned by 'layer.getPrimitives()' shows that the length decreases by one each time a primitive is hidden. The following code illustrates the problem:
    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <meta charset="utf-8" />
        <script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol?callback=GetMap' async defer></script>
        <script type='text/javascript'>
        var map, layer;
        function GetMap() {
            map = new Microsoft.Maps.Map('#myMap', {credentials: ''});
            layer = new Microsoft.Maps.Layer();
            layer.add(Microsoft.Maps.TestDataGenerator.getPushpins(5, map.getBounds()));
    	map.layers.insert(layer);
        }
        </script>
    </head>
    <body>
        <div id="myMap" style=";width:600px;height:400px;"></div>
    	<input type="button" value="Hide First Item" onclick="layer.getPrimitives()[0].setOptions({visible: false});document.getElementById('result').innerText = layer.getPrimitives().length;return false;" />
    	Total Items in Layer: <span id="result" />
    </body>
    </html>


    Friday, July 1, 2016 9:01 AM

Answers

  • Good news, the dev team has looked into this issue and fixed it. The fix is currently in the experimental branch of V8 and will be rolled into the main release branch in our next monthly update which will like occur in the first full week of September.

    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Wednesday, August 10, 2016 6:59 PM
    • Marked as answer by Ricky_Brundritt Wednesday, August 10, 2016 7:00 PM
    • Unmarked as answer by Ricky_Brundritt Wednesday, August 10, 2016 7:00 PM
    • Marked as answer by gwenci Thursday, August 11, 2016 7:56 AM
    Wednesday, August 10, 2016 6:59 PM

All replies

  • I'll talk to our devs about this to see if this is expected. Note that if you change the visibility of the pushpin instance later it re appears and the number of items in the getPrimitives function increases. It looks like this function currently only returns the shapes that are visible.

    [Blog] [twitter] [LinkedIn]

    Friday, July 1, 2016 4:45 PM
  • Good news, the dev team has looked into this issue and fixed it. The fix is currently in the experimental branch of V8 and will be rolled into the main release branch in our next monthly update which will like occur in the first full week of September.

    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Wednesday, August 10, 2016 6:59 PM
    • Marked as answer by Ricky_Brundritt Wednesday, August 10, 2016 7:00 PM
    • Unmarked as answer by Ricky_Brundritt Wednesday, August 10, 2016 7:00 PM
    • Marked as answer by gwenci Thursday, August 11, 2016 7:56 AM
    Wednesday, August 10, 2016 6:59 PM
  • That's great. Thanks for your help
    Thursday, August 11, 2016 7:56 AM