Replace heatmap with density dots for all zoom levels

Remove Leaflet.heat in favor of consistent density dot visualization:
- Zoom 1-5: Density dots with 40% more density (24px spacing)
- Zoom 6-11: Density dots with normal spacing (40px)
- Zoom 12-15: Numbered cluster circles
- Zoom 16+: Individual property markers

Density dots provide clearer visualization than heatmap blobs for
high-density property data.

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Hanson.xyz Dev
2025-12-16 00:58:59 -06:00
parent 93d5b01111
commit 7c3c322449
4 changed files with 19 additions and 42 deletions
@@ -28,6 +28,11 @@ class MLS_Cluster {
*/
const DENSITY_DOT_SPACING = 40;
/**
* Denser spacing for very zoomed out views (40% more dense = 60% of normal)
*/
const DENSITY_DOT_SPACING_DENSE = 24;
/**
* Maximum properties to return as individual markers
* Above this threshold, return clusters
@@ -37,8 +42,8 @@ class MLS_Cluster {
/**
* Zoom thresholds for visualization modes
*/
const ZOOM_HEATMAP_MAX = 7; // 3-7: heatmap only
const ZOOM_DENSITY_MAX = 11; // 8-11: density dots
const ZOOM_DENSE_MAX = 5; // 1-5: density dots (40% more dense)
const ZOOM_DENSITY_MAX = 11; // 6-11: density dots (normal)
const ZOOM_CLUSTER_MAX = 15; // 12-15: numbered clusters
// 16+: individual markers
@@ -274,14 +279,14 @@ class MLS_Cluster {
$zoom = (int) $args['zoom'];
// Determine visualization mode based on zoom level
// Zoom 3-7: Heatmap (just return points for client-side heatmap)
if ($zoom <= self::ZOOM_HEATMAP_MAX) {
return $this->get_heatmap_data($where_sql, $values, $total);
// Zoom 1-5: Density dots (40% more dense)
if ($zoom <= self::ZOOM_DENSE_MAX) {
return $this->get_density_data($where_sql, $values, $zoom, $center_lat, $total, self::DENSITY_DOT_SPACING_DENSE);
}
// Zoom 8-11: Density dots (small colored circles without numbers)
// Zoom 6-11: Density dots (normal spacing)
if ($zoom <= self::ZOOM_DENSITY_MAX) {
return $this->get_density_data($where_sql, $values, $zoom, $center_lat, $total);
return $this->get_density_data($where_sql, $values, $zoom, $center_lat, $total, self::DENSITY_DOT_SPACING);
}
// Zoom 12-15: Numbered clusters (or individual if low count)
@@ -347,15 +352,17 @@ class MLS_Cluster {
* @param int $zoom Map zoom level
* @param float $center_lat Center latitude for Mercator adjustment
* @param int $total Total count
* @param int $pixel_spacing Pixel spacing for grid cells
* @return array
*/
private function get_density_data($where_sql, $values, $zoom, $center_lat, $total) {
private function get_density_data($where_sql, $values, $zoom, $center_lat, $total, $pixel_spacing = null) {
global $wpdb;
$table = $this->db->properties_table();
$pixel_spacing = $pixel_spacing ?: self::DENSITY_DOT_SPACING;
// Use smaller grid cells for density dots
list($lat_step, $lng_step) = $this->get_grid_step_for_zoom($zoom, $center_lat, self::DENSITY_DOT_SPACING);
list($lat_step, $lng_step) = $this->get_grid_step_for_zoom($zoom, $center_lat, $pixel_spacing);
$sql = "SELECT
FLOOR(latitude / %f) as lat_cell,