144 posts
  • Bought between 100 and 499 items
  • Exclusive Author
  • Germany
  • Has been a member for 5-6 years
  • Referred between 10 and 49 users
joomlaianer says

I`ve a question.

i made a business directory with custom post types. is it possible to let users search after the category or taxonomies and add a radius search?

for example.

i search in category a with a radius search of 10 miles.

hope u understand what i`m talking about :)

144 posts
  • Bought between 100 and 499 items
  • Exclusive Author
  • Germany
  • Has been a member for 5-6 years
  • Referred between 10 and 49 users
joomlaianer says

no solutions ?

731 posts
  • Elite Author
  • Attended a Community Meetup
  • Has been a member for 4-5 years
  • Sold between 100 000 and 250 000 dollars
  • Bought between 50 and 99 items
  • Exclusive Author
  • Most Wanted Bounty Winner
+2 more
mordauk says

It is possible, though it’s rather difficult. You would have to store the locations in post meta fields, and then look for ones that are near the search when you search for a radius. The difficult part is that you have to find a way to calculate distances from each place’s location that is stored in the meta field.

235 posts
  • Has been a member for 4-5 years
  • Sold between 10 000 and 50 000 dollars
  • Exclusive Author
  • Bought between 1 and 9 items
  • Referred between 1 and 9 users
  • United Kingdom
phpdude says

Basically, what you need to do is when a custom post is added/updated it needs to Geocode via Google the Lat and Long from the postcode/zip code etc and store these in separate fields.

Then you add a text input to search, the input for this is Geocoded via Google too to get the lat and long of the location, then parse this through a fairly simple SQL which calculates the distance between the the search lat and long and each of the rows lat and long, then only show ones which are within X miles.

Geocode like so:
$address = 'London, UK';
$lines = explode("\n",file_get_contents('http://maps.google.com/maps/geo?q='.urlencode($address).'&output=csv&key='.$google_map_key));
list($x,$x,$lat,$long) = explode(',', $lines[0]);
SQL like so:
$miles = 5; // Show only results within 5 miles
mysql_query("SELECT *, truncate((degrees(acos( sin(radians(`lat`)) * sin( radians('".$lat."')) + cos(radians(`lat`)) * cos( radians('".$lat."')) * cos( radians(`long` - '".$long."') ) ) ) * 69.09),1) as distance FROM `postcodes` WHERE truncate((degrees(acos( sin(radians(`lat`)) * sin( radians('".$lat."')) + cos(radians(`lat`)) * cos( radians('".$lat."')) * cos( radians(`long` - '".$long."') ) ) ) * 69.09),1) <= ".$miles." ORDER BY `distance` ASC");

SQL is just off the top of my head, so hopefully it will work, if not it will point you in the right direction.

144 posts
  • Bought between 100 and 499 items
  • Exclusive Author
  • Germany
  • Has been a member for 5-6 years
  • Referred between 10 and 49 users
joomlaianer says

what would it cost to develop such a plugin ? unfournetly i cant write php :)

186 posts
  • Has been a member for 2-3 years
  • Philippines
nicole_anderson says

Hello joomlaianer!

If you really prefer custom plugin, then go to my profile and contact me and lets go from there. I’d be waiting on your mail then.

Regards, Nicole

2 posts
  • Exclusive Author
  • Has been a member for 2-3 years
  • Sold between 1 000 and 5 000 dollars
  • United Kingdom
kodefoundry says

Having the Lng/Lat coordinates stored in the postmeta table makes it difficult (if not impossible) to do sorting and advanced distance queries. Ideally, you should have a separate table with appropriate data types for columns (double/float). I’ve done quite a bit with GiS systems in the past so if you are still looking to get this developed, feel free to send me a message via by profile page.

Kevin

1 post
  • Bought between 1 and 9 items
  • Has been a member for 1-2 years
rszecsodi says

I have just found this plugin it works for me on my premiumpress install.

http://www.web-directory-service.com/universalwp/wp-radius-search/
by
by
by
by
by
by