Search code examples
azure-maps

Zooming in on a cluster eventually resolves to a single pin


I have a case with 3 pins at the same location. Zoomed out it renders as a cluster. But when I zoom in, generally somewhere between 16 & 18, it changes to a single pin.

What's going on here? Shouldn't it remain a cluster even at maximum zoom? Is there a way to keep it clustered? Because this way, the other 2 pins are gone - the user cannot access them.


Solution

  • The DataSource class has an option called clusterMaxZoom which specifies the maximum zoom level the map will cluster points to. This is set to 18 by default. If you have points that will be at the same location, it would best to set this to 24 (max possible zoom level of the map). You can either set this when creating the data source or update the options afterwards. It would be better to set this before adding your data so that it calculates the clusters once.

    var myDataSource = new atlas.source.DataSource(null, { 
        cluster: true, 
        clusterMaxZoom: 24 
    });
    

    or

    myDataSource.SetOptions({ clusterMaxZoom: 24 });