Fully relative heatmap for Azure Maps?

Jonathan 20 Reputation points
2025-08-29T08:27:29.0333333+00:00

Is there a way to generate a fully relative heat map layer in Azure Maps? Specifically, I need a heatmap where:

  1. At any given zoom level, only the single highest-density cluster is colored red (maximum intensity)
  2. All other clusters are colored relative to this maximum, ensuring there's always exactly one red zone visible
  3. When zooming in/out, if a different cluster becomes the highest-density area in the viewport, that cluster becomes red and the previous red cluster adjusts to a cooler color accordingly

This would essentially normalize the color scale dynamically based on the maximum density visible in the current map extent, rather than using a fixed global scale.

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
{count} votes

Answer accepted by question author
  1. Manas Mohanty 11,690 Reputation points Microsoft External Staff Moderator
    2025-09-12T02:55:34.3566667+00:00

    Hi Jonathan

    Attached source for Zoomable heat map.User's image

    https://github.com/Azure-Samples/AzureMapsCodeSamples/blob/main/Samples/Heat%20Map%20Layer/Consistent%20zoomable%20Heat%20Map/Consistent%20zoomable%20Heat%20Map.htmlI think that consistent Zoomable heat maps should act as base reference for modification.

    Normalizing heat map weights and re-rendering a new heat map with updated weights should give our desired results

        { position: [30.3322, -81.6557], weight: 0.8 },   // Jacksonville
                { position: [39.2904, -76.6122], weight: 0.85 },  // Baltimore
                { position: [43.651070, -79.347015], weight: 0.9 } // Toronto
            ];
    
       map.events.add('zoomend', updateHeatMap);
       map.events.add('moveend', updateHeatMap);
    
            function updateHeatMap() {
                var bounds = map.getCamera().bounds;
                var visiblePoints = heatMapData.filter(function (p) {
                    return p.position[1] >= bounds[0][0] && p.position[1] <= bounds[1][0] &&
                           p.position[0] >= bounds[0][1] && p.position[0] <= bounds[1][1];
                });
    
                if (visiblePoints.length === 0) return;
    
                var maxDensity = Math.max(...visiblePoints.map(p => p.weight));
    
                var features = heatMapData.map(function (p) {
                    var normalizedWeight = p.weight / maxDensity;
                    return new atlas.data.Feature(new atlas.data.Point(p.position), {
                        weight: normalizedWeight
                    });
                });
    
    
    

    Have not come with a working code

    Hope the logic of normalizing map weights upon hearing zoom or move end helps and re-rendering a new heat map helps.

    Thank you

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.