none
Hide traffic will fire map click event?(V8) RRS feed

  • Question

  • Hi all:

        I find when I hide traffic layer, it will occurs map click event, is that a bing map bug? follow is my test code.

    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <meta charset="utf-8" />
        <script type='text/javascript' src='https://www.bing.com/api/maps/mapcontrol?callback=GetMap' async defer></script>
        <script type='text/javascript' src='/BingMapsCredentials.js'></script>
        <script type='text/javascript'>
        var map, trafficManager;
    
        function GetMap()
        {
            map = new Microsoft.Maps.Map('#myMap', {
                credentials: YourBingMapsKey
            });
    
            Microsoft.Maps.Events.addHandler(map, 'click', function (e)
            {
            	alert(1);
            });
    
            //Load traffic module.
            Microsoft.Maps.loadModule('Microsoft.Maps.Traffic', function () {
                //Create an instance of the traffic manager and bind to map.
                trafficManager = new Microsoft.Maps.Traffic.TrafficManager(map);
    
                //Display the traffic data layer.
                trafficManager.show();
            });
    
    
    
            setTimeout(function () { trafficManager.hide(); }, 5000);
        }
        </script>
    </head>
    <body>
        <div id="myMap" style=";width:600px;height:400px;"></div>
    </body>
    </html>

    • Edited by s000rd Wednesday, April 12, 2017 2:09 AM
    Wednesday, April 12, 2017 2:08 AM

Answers

  • Very odd. Haven't seen this one before. Will log this as a bug.

    Strangely enough, if you move away from the legacy hide() function to the setOptions function this works fine. For example:

    trafficManager.setOptions({visible: false});


    [Blog] [twitter] [LinkedIn]


    • Edited by Ricky_Brundritt Wednesday, April 12, 2017 3:53 PM
    • Proposed as answer by Ricky_Brundritt Wednesday, April 12, 2017 3:53 PM
    • Marked as answer by s000rd Thursday, April 13, 2017 7:17 AM
    Wednesday, April 12, 2017 3:50 PM