Add hover pins for clustered properties, disable grouping under 30 markers

- Add data-lat/data-lng attributes to MLS property cards
- Create temporary highlighted pin on card hover when marker is clustered
- Show individual pins (no grouping) when <= 30 properties in viewport
- Add markerLayer for unclustered markers to bypass client-side clustering
- Show loading spinner immediately on map move to abort image loads

🤖 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-17 02:31:23 -06:00
parent 8cd630593d
commit dfad0f57e6
4 changed files with 114 additions and 11 deletions
@@ -65,6 +65,33 @@ class MLS_Cluster {
$this->db = $db;
}
/**
* Get state filter SQL clause
*
* @return string SQL clause or empty string
*/
private function get_state_filter() {
if (!defined('MLS_ALLOWED_STATES') || empty(MLS_ALLOWED_STATES)) {
return '';
}
global $wpdb;
$states = array_map(function($state) use ($wpdb) {
return $wpdb->prepare('%s', $state);
}, MLS_ALLOWED_STATES);
return 'state_or_province IN (' . implode(',', $states) . ')';
}
/**
* Get the TBD address exclusion filter
* Excludes properties with "TBD" as street number
*
* @return string SQL clause
*/
private function get_tbd_exclusion_filter() {
return "(street_number IS NULL OR (street_number != 'TBD' AND street_number NOT LIKE 'TBD %'))";
}
/**
* Encode latitude/longitude to geohash
*
@@ -225,6 +252,15 @@ class MLS_Cluster {
$where = array('mlg_can_view = 1', 'latitude IS NOT NULL', 'longitude IS NOT NULL');
$values = array();
// Add state filter (MN, IA only)
$state_filter = $this->get_state_filter();
if ($state_filter) {
$where[] = $state_filter;
}
// Exclude TBD addresses
$where[] = $this->get_tbd_exclusion_filter();
if ($args['status']) {
$where[] = 'standard_status = %s';
$values[] = $args['status'];
@@ -276,8 +312,8 @@ class MLS_Cluster {
$total = (int) $wpdb->get_var($count_sql);
}
// If very few properties, always show individual markers (no grouping)
if ($total < self::MIN_FOR_GROUPING) {
// If few properties, always show individual markers (no grouping)
if ($total <= self::MIN_FOR_GROUPING) {
return $this->get_individual_markers($where_sql, $values, $total);
}
@@ -541,6 +577,15 @@ class MLS_Cluster {
$where = array('mlg_can_view = 1', 'latitude IS NOT NULL', 'longitude IS NOT NULL');
$values = array();
// Add state filter (MN, IA only)
$state_filter = $this->get_state_filter();
if ($state_filter) {
$where[] = $state_filter;
}
// Exclude TBD addresses
$where[] = $this->get_tbd_exclusion_filter();
if (!empty($args['status'])) {
$where[] = 'standard_status = %s';
$values[] = $args['status'];