none
Bing Maps V8 clustered layer issues with events on individual pushping RRS feed

  • Question

  • There seems to be a pretty big problem in the clustering module in bing maps V8. When you create a clustered layer and add pushpins to is with individual event handlers (on click) the following behavior occurs:

    When you zoom into the map (slowly) until a cluster expands and reveals an individual pushpin, then clicking on the pushpin will trigger the even as expected. Now, make a change to the map (either continue to zoom or simple drag the map a little to left, right top or bottom) and click again on the SAME pushpin. The event will not be triggered. 

    This is reproducible in the online Bing Map SDK:

    go to https://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk#clusteringMeanAverage+JS and replace the code in the window with the below (it adds an event handler to each pushpin). you will be the problem. 

    var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
        credentials: 'Your Bing Maps Key',
        center: new Microsoft.Maps.Location(39.393486, -98.100769),
        zoom: 3
    });
    Microsoft.Maps.loadModule('Microsoft.Maps.Clustering', function () {
        // Creating sample Pushpin data within map view
        var pushpins = Microsoft.Maps.TestDataGenerator.getPushpins(1000, map.getBounds());
     pushpins.forEach(p => {
      Microsoft.Maps.Events.addHandler(p, 'click', function () { console.log(p) }); 
     })
        var clusterLayer = new Microsoft.Maps.ClusterLayer(pushpins, { gridSize: 100 });
        map.layers.insert(clusterLayer);
    });

    Another way to reproduce is to disable clustering on the map like:

    var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
        credentials: 'Your Bing Maps Key',
        center: new Microsoft.Maps.Location(39.393486, -98.100769),
        zoom: 3
    });
    Microsoft.Maps.loadModule('Microsoft.Maps.Clustering', function () {
        // Creating sample Pushpin data within map view
        var pushpins = Microsoft.Maps.TestDataGenerator.getPushpins(1000, map.getBounds());
     pushpins.forEach(p => {
      Microsoft.Maps.Events.addHandler(p, 'click', function () { console.log(p) }); 
     })
        var clusterLayer = new Microsoft.Maps.ClusterLayer(pushpins, { gridSize: 100, clusteringEnabled: false });
        map.layers.insert(clusterLayer);
    });

    When the map loads, clicking on any pushpin will log to the console as expected. Zoom in (or move the map in any other way) and clicks on any pushpin will no longer log. 

    Btw: The event handlers stay on the pushpins, I was able to confirm that. So I suspect that this is something where the pushpins clicks are intercepted by the layer and not correctly forwarded...

    Any thoughts or suggestions on how to deal with this as it makes the clustering functionality pretty much unusable....

    Friday, May 19, 2017 10:14 PM

Answers

  • This is a known issue that has been discussed at length in several other posts. This is fixed in the experimental branch. The main release branch will be updated at the end of this month.

    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Friday, May 19, 2017 11:43 PM
    • Marked as answer by tschueler Saturday, May 20, 2017 12:51 AM
    Friday, May 19, 2017 11:43 PM
  • Every 1 to 3 months everything in the experimental branch which is known to have been tested and working is rolled into the main release branch. When the main release update is pushed live it is usually a week behind the experimental branch as we do at least a weeks work of testing on the merge to reduce new issues being introduced due to the merge.

    We have pushed back the next release update about a week and a half as there where a number of other V7 migration issues the team has been working on that we wanted to get in before doing the update. So by the end of the second week of June, the main release branch should be updated.


    [Blog] [twitter] [LinkedIn]

    Thursday, June 1, 2017 1:11 AM
  • Note that you can add events on the cluster layer itself instead of the individual pushpins. This doesn't have the issue and is also a better recommended approach as it uses a lot less memory and is faster. Here is a code sample: https://github.com/Microsoft/BingMapsV8CodeSamples/blob/master/Samples/Clustering/Clustering_PushpinList.html

    [Blog] [twitter] [LinkedIn]

    Thursday, May 25, 2017 9:52 PM
  • The next update is next week. On July 1st parts of v7 will stop functioning and the API will be take down over a period of time. Eventually it will redirect to the v8 API. 

    [Blog] [twitter] [LinkedIn]

    Friday, June 9, 2017 8:21 PM

All replies

  • http://bingmapsv8samples.azurewebsites.net/#Clustering_PushpinList

    Another example that illustrates the issue. When the map loads, click on an individual pin will show an infobox. Interact with the map (zoom, drag) and that same pin will no longer show the infobox on click.

    Friday, May 19, 2017 10:18 PM
  • This is a known issue that has been discussed at length in several other posts. This is fixed in the experimental branch. The main release branch will be updated at the end of this month.

    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Friday, May 19, 2017 11:43 PM
    • Marked as answer by tschueler Saturday, May 20, 2017 12:51 AM
    Friday, May 19, 2017 11:43 PM
  • Oh man, just discovered this during our v7 to v8 migration attempt. thought I was going crazy, thanks for posting!
    Thursday, May 25, 2017 5:59 PM
  • Note that you can add events on the cluster layer itself instead of the individual pushpins. This doesn't have the issue and is also a better recommended approach as it uses a lot less memory and is faster. Here is a code sample: https://github.com/Microsoft/BingMapsV8CodeSamples/blob/master/Samples/Clustering/Clustering_PushpinList.html

    [Blog] [twitter] [LinkedIn]

    Thursday, May 25, 2017 9:52 PM
  • This is a known issue that has been discussed at length in several other posts. This is fixed in the experimental branch. The main release branch will be updated at the end of this month.

    Thanks for addressing the issue in a timely manner. I was able to reproduce the same issue in release branch and tested it working in experimental branch. Thanks for the great job!

    btw, what will the release plan look like? Will it merge all changes from the experimental branch or pick&choose? What determines an update to the release branch? I am upgrading from v7 to v8 and encountering some issues with the release branch. All these issues have been addressed so far in the experimental branch. I am hoping to have these fixes in the release branch soon so that we can test them before the v7 is deprecated. Thanks!

    Wednesday, May 31, 2017 11:23 PM
  • Every 1 to 3 months everything in the experimental branch which is known to have been tested and working is rolled into the main release branch. When the main release update is pushed live it is usually a week behind the experimental branch as we do at least a weeks work of testing on the merge to reduce new issues being introduced due to the merge.

    We have pushed back the next release update about a week and a half as there where a number of other V7 migration issues the team has been working on that we wanted to get in before doing the update. So by the end of the second week of June, the main release branch should be updated.


    [Blog] [twitter] [LinkedIn]

    Thursday, June 1, 2017 1:11 AM
  • In an email dated May 31, 2017, it was stated that "After June 30, support for the V7 control will end and service availability will no longer be guaranteed".

    Can I assume the V7 service will remain available until this bug is fixed and pushed out to the 'release' branch?

    Friday, June 9, 2017 7:09 PM
  • The next update is next week. On July 1st parts of v7 will stop functioning and the API will be take down over a period of time. Eventually it will redirect to the v8 API. 

    [Blog] [twitter] [LinkedIn]

    Friday, June 9, 2017 8:21 PM
  • Was the release branch updated yet? 
    Monday, June 19, 2017 3:50 PM
  • There were some issues last week which delayed the release roll out. The update is going out now.

    [Blog] [twitter] [LinkedIn]

    Monday, June 19, 2017 6:31 PM
  • There were some issues last week which delayed the release roll out. The update is going out now.

    Any updates on the release branch yet? I was referring to the "What's New" page and don't see updates for the June release yet. Here is the link:

    https://msdn.microsoft.com/en-us/library/mt770019.aspx

    Interestingly, when I switched to release branch the fixes I'll expect to be merged from experimental branch is in place. Not sure if the release branch update is complete at this point.

    Wednesday, June 21, 2017 3:34 PM