Fix city/zip filtering and improve map hover behavior
MLS Query Changes: - Use exact city/postal_code matching instead of radius search - Fixes city filter returning 1700+ results instead of 97 for Ramsey Cluster Endpoint: - Parse "City, SS" format to extract city name before querying - Fixes pins not showing when city filter applied Property Filters JS: - Always fit map bounds when filter changes (not just on no intersection) - Fit bounds on initial page load when URL has filters - Show temporary hover pin when marker is clustered or outside viewport - Uses markerCluster.getVisibleParent() to detect clustered markers Property Results: - Add zip code parameter handling for URL filters 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -209,40 +209,13 @@ class MLS_Query {
|
||||
|
||||
// City and postal_code are mutually exclusive - city takes priority
|
||||
if ($args['city']) {
|
||||
// Look up city coordinates for radius search
|
||||
$city_coords = $this->get_city_coordinates($args['city']);
|
||||
if ($city_coords) {
|
||||
// Match exact city OR within 15 miles of city center
|
||||
$distance_filter = $this->get_distance_filter_sql(
|
||||
$city_coords['latitude'],
|
||||
$city_coords['longitude'],
|
||||
15 // miles
|
||||
);
|
||||
$where[] = "(city = %s OR ({$distance_filter}))";
|
||||
$values[] = $args['city'];
|
||||
} else {
|
||||
// Fallback to exact match if city not in geo table
|
||||
$where[] = 'city = %s';
|
||||
$values[] = $args['city'];
|
||||
}
|
||||
// Exact city match
|
||||
$where[] = 'city = %s';
|
||||
$values[] = $args['city'];
|
||||
} elseif ($args['postal_code']) {
|
||||
// Only apply postal_code filter if city is not set
|
||||
// Look up zip code coordinates for radius search
|
||||
$zip_coords = $this->get_zipcode_coordinates($args['postal_code']);
|
||||
if ($zip_coords) {
|
||||
// Match exact zip code OR within 20 miles of zip code center
|
||||
$distance_filter = $this->get_distance_filter_sql(
|
||||
$zip_coords['latitude'],
|
||||
$zip_coords['longitude'],
|
||||
20 // miles
|
||||
);
|
||||
$where[] = "(postal_code = %s OR ({$distance_filter}))";
|
||||
$values[] = $args['postal_code'];
|
||||
} else {
|
||||
// Fallback to exact match if zip code not in geo table
|
||||
$where[] = 'postal_code = %s';
|
||||
$values[] = $args['postal_code'];
|
||||
}
|
||||
// Exact postal code match
|
||||
$where[] = 'postal_code = %s';
|
||||
$values[] = $args['postal_code'];
|
||||
} elseif ($args['center_lat'] && $args['center_lng']) {
|
||||
// Direct lat/lng radius search (from homepage location search)
|
||||
$distance_filter = $this->get_distance_filter_sql(
|
||||
@@ -548,40 +521,13 @@ class MLS_Query {
|
||||
|
||||
// City and postal_code are mutually exclusive - city takes priority
|
||||
if (!empty($args['city'])) {
|
||||
// Look up city coordinates for radius search
|
||||
$city_coords = $this->get_city_coordinates($args['city']);
|
||||
if ($city_coords) {
|
||||
// Match exact city OR within 15 miles of city center
|
||||
$distance_filter = $this->get_distance_filter_sql(
|
||||
$city_coords['latitude'],
|
||||
$city_coords['longitude'],
|
||||
15 // miles
|
||||
);
|
||||
$where[] = "(city = %s OR ({$distance_filter}))";
|
||||
$values[] = $args['city'];
|
||||
} else {
|
||||
// Fallback to exact match if city not in geo table
|
||||
$where[] = 'city = %s';
|
||||
$values[] = $args['city'];
|
||||
}
|
||||
// Exact city match
|
||||
$where[] = 'city = %s';
|
||||
$values[] = $args['city'];
|
||||
} elseif (!empty($args['postal_code'])) {
|
||||
// Only apply postal_code filter if city is not set
|
||||
// Look up zip code coordinates for radius search
|
||||
$zip_coords = $this->get_zipcode_coordinates($args['postal_code']);
|
||||
if ($zip_coords) {
|
||||
// Match exact zip code OR within 20 miles of zip code center
|
||||
$distance_filter = $this->get_distance_filter_sql(
|
||||
$zip_coords['latitude'],
|
||||
$zip_coords['longitude'],
|
||||
20 // miles
|
||||
);
|
||||
$where[] = "(postal_code = %s OR ({$distance_filter}))";
|
||||
$values[] = $args['postal_code'];
|
||||
} else {
|
||||
// Fallback to exact match if zip code not in geo table
|
||||
$where[] = 'postal_code = %s';
|
||||
$values[] = $args['postal_code'];
|
||||
}
|
||||
// Exact postal code match
|
||||
$where[] = 'postal_code = %s';
|
||||
$values[] = $args['postal_code'];
|
||||
} elseif (!empty($args['center_lat']) && !empty($args['center_lng'])) {
|
||||
// Direct lat/lng radius search (from homepage location search)
|
||||
$radius = !empty($args['radius']) ? (int) $args['radius'] : 30;
|
||||
@@ -806,40 +752,13 @@ class MLS_Query {
|
||||
|
||||
// City and postal_code are mutually exclusive - city takes priority
|
||||
if (!empty($args['city'])) {
|
||||
// Look up city coordinates for radius search
|
||||
$city_coords = $this->get_city_coordinates($args['city']);
|
||||
if ($city_coords) {
|
||||
// Match exact city OR within 15 miles of city center
|
||||
$distance_filter = $this->get_distance_filter_sql(
|
||||
$city_coords['latitude'],
|
||||
$city_coords['longitude'],
|
||||
15 // miles
|
||||
);
|
||||
$where[] = "(city = %s OR ({$distance_filter}))";
|
||||
$values[] = $args['city'];
|
||||
} else {
|
||||
// Fallback to exact match if city not in geo table
|
||||
$where[] = 'city = %s';
|
||||
$values[] = $args['city'];
|
||||
}
|
||||
// Exact city match
|
||||
$where[] = 'city = %s';
|
||||
$values[] = $args['city'];
|
||||
} elseif (!empty($args['postal_code'])) {
|
||||
// Only apply postal_code filter if city is not set
|
||||
// Look up zip code coordinates for radius search
|
||||
$zip_coords = $this->get_zipcode_coordinates($args['postal_code']);
|
||||
if ($zip_coords) {
|
||||
// Match exact zip code OR within 20 miles of zip code center
|
||||
$distance_filter = $this->get_distance_filter_sql(
|
||||
$zip_coords['latitude'],
|
||||
$zip_coords['longitude'],
|
||||
20 // miles
|
||||
);
|
||||
$where[] = "(postal_code = %s OR ({$distance_filter}))";
|
||||
$values[] = $args['postal_code'];
|
||||
} else {
|
||||
// Fallback to exact match if zip code not in geo table
|
||||
$where[] = 'postal_code = %s';
|
||||
$values[] = $args['postal_code'];
|
||||
}
|
||||
// Exact postal code match
|
||||
$where[] = 'postal_code = %s';
|
||||
$values[] = $args['postal_code'];
|
||||
}
|
||||
|
||||
if (!empty($args['min_price'])) {
|
||||
|
||||
Regular → Executable
+4
@@ -256,6 +256,10 @@ final class MLS_Plugin {
|
||||
$status = isset($_REQUEST['status']) ? sanitize_text_field($_REQUEST['status']) : 'Active';
|
||||
$property_type = isset($_REQUEST['property_type']) ? sanitize_text_field($_REQUEST['property_type']) : null;
|
||||
$city = isset($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : null;
|
||||
// Parse "City, SS" format - extract just the city name
|
||||
if ($city && preg_match('/^(.+),\s*([A-Z]{2})$/', $city, $matches)) {
|
||||
$city = $matches[1];
|
||||
}
|
||||
$min_price = isset($_REQUEST['min_price']) ? (int) $_REQUEST['min_price'] : null;
|
||||
$max_price = isset($_REQUEST['max_price']) ? (int) $_REQUEST['max_price'] : null;
|
||||
$min_beds = isset($_REQUEST['min_beds']) ? (int) $_REQUEST['min_beds'] : null;
|
||||
|
||||
Reference in New Issue
Block a user