Coordinates sorting & bgmp_categories
-
Hello. First of all, thank you for this awesome plugin!
I try to have a function which returns closest places of given category.
After some googling, I managed to construct SQL query that sorts by distance, but I can’t incorporate bgmp_category taxonomy into it.Any idea how can I specify category in this query? I think this is common request, so I wonder what others came up with & what’s the right way.
Or can the getMapPlacemarks() function be altered to sort by distance (from given coords)?
Thank you for any idea!
SQL:
4 $nearbyPlaces = $wpdb->get_results(· 5 "SELECT DISTINCT 6 bgmp_latitude.post_id, 7 bgmp_latitude.meta_key, 8 bgmp_latitude.meta_value, 9 bgmp_longitude.meta_value, 10 ((ACOS(SIN($lat * PI() / 180) * SIN(bgmp_latitude.meta_value * PI() / 180) + COS($lat * PI() / 180) * COS(bgmp_latitude.meta_value * PI() / 180) * COS(($long - bgmp_longitude.meta_value) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS distance, 11 wp_posts.post_status as status 12 FROM 13 wp_postmeta AS bgmp_latitude 14 LEFT JOIN wp_postmeta as bgmp_longitude ON bgmp_latitude.post_id = bgmp_longitude.post_id 15 INNER JOIN wp_posts ON wp_posts.ID = bgmp_latitude.post_id 16 WHERE bgmp_latitude.meta_key = 'bgmp_latitude' AND bgmp_longitude.meta_key = 'bgmp_longitude' 17 HAVING distance < $distance AND status = 'publish' 18 ORDER BY distance ASC 19 LIMIT $pageSize OFFSET $offset;" 20 );
https://www.ads-software.com/plugins/basic-google-maps-placemarks/
- The topic ‘Coordinates sorting & bgmp_categories’ is closed to new replies.