Hi Jonathan
Attached source for Zoomable heat map.
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