BingMaps Is it possible to disable clustering below certain zoom level?

Viewed 137

My map pushpins are relatively close to each other and even on a big zoom I still see them clustered. I solved this issue by spreading the clustered pushpins by some random distance 5-10 meters.

I need more accurate solution so my idea is to disable the clustering below the certain zoom level, but I didn't find any way how to do it.

2 Answers

There is no option to disable clustering in the clustering layer in Bing Maps, but what you can do is monitor the zoom level of the map, and when it gets to a certain point, hide the cluster layer and load a new layer that isn't clustered. Unfortunately this means having two copies of your data in memory.

If you haven't fully committed to using the Bing Maps platform, you may also want to take a look at Azure Maps. The Azure Maps web SDK does things a bit differently where you would keep your data in a single data source and attach rendering layers to it. Clustering is turned on in the data source and has a max zoom level option for clustering.

Here is some examples: https://azuremapscodesamples.azurewebsites.net/index.html?search=cluster Here is documentation: https://docs.microsoft.com/en-us/azure/azure-maps/clustering-point-data-web-sdk

There is an option clusteringEnabled now on ClusterLayerOptions which will disable clustering without losing the whole layer.

eg:

  Microsoft.Maps.Events.addHandler(this.map, 'viewchangeend', () => {        
              // de-cluster at highest zoom level
              this.clusterLayer?.setOptions({
                clusteringEnabled:
                  this.map.getZoom() < this.map.getZoomRange().max
              });
            });
Related