none
Problem using map.layers.clear() when heatmap is loaded. RRS feed

  • Question

  • I recently started having issues in production clearing a map using the call map.layers.clear().  This error only occurs when a heat layer is present in combination with a data layer with pins.  The call works fine when there are only data layers.  The error I receive is "SCRIPT5009: 'Helper' is not defined".  My code has not changed in 4 months and we just started seeing the issue in the past week or so.  I am also able to duplicate the issue in the Bing Maps SDK portal.  Is anyone else experiencing this issue? 
    Thursday, April 19, 2018 6:14 PM

Answers

  • Thanks for this. I was able to reproduce and have alerted our Development Team. If you are an Enterprise customer, look into your contract details and send in an email so we can update you. 
    Thursday, April 19, 2018 7:04 PM
    Moderator

All replies

  • I wasn't able to reproduce. Can you provide sample code that would work on the ISDK?
    Thursday, April 19, 2018 6:17 PM
    Moderator
  • Sure. Go to Layer& Visulizations --> HeatMap Module --> Set Locations.  Paste the below code in the JavaScript tab and run. In the console you will receive the error.

    var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
        /* No need to set credentials if already passed in URL */
        center: new Microsoft.Maps.Location(39.393486, -98.100769),
        zoom: 3 });
     
    Microsoft.Maps.loadModule('Microsoft.Maps.HeatMap', function () {
        // Creating sample Pushpin data within map view
        var locations = getRandomLocations(map, 1000);
        var heatMap = new Microsoft.Maps.HeatMapLayer(locations);
        map.layers.insert(heatMap); 
     setTimeout(function(){
       map.layers.clear();
     },2000)
       
    });
    function getRandomLocations(map, count) {
        var mapDiv = map.getRootElement();
        var locations = [];
        for (var i = 0; i < count; i++) {
            locations.push(map.tryPixelToLocation(new Microsoft.Maps.Point(mapDiv.clientWidth * Math.random(), mapDiv.clientHeight * Math.random()), Microsoft.Maps.PixelReference.control));
        }
        return locations;
    }

    Thursday, April 19, 2018 6:35 PM
  • Thanks for this. I was able to reproduce and have alerted our Development Team. If you are an Enterprise customer, look into your contract details and send in an email so we can update you. 
    Thursday, April 19, 2018 7:04 PM
    Moderator
  • Thank you for following up so quickly.  I will contact our department that handles the contract.  Thanks again.
    Thursday, April 19, 2018 7:09 PM