144 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 10+ members
  • Has collected 100+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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
  • Has been part of the Envato Community for over 5 years
  • Has referred 10+ members
  • Has collected 100+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
joomlaianer says

no solutions ?

737 posts
  • Has referred 500+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+7 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.

240 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Has been part of the Envato Community for over 4 years
+2 more
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
  • Has been part of the Envato Community for over 5 years
  • Has referred 10+ members
  • Has collected 100+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
joomlaianer says

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

186 posts
  • Has been part of the Envato Community for over 3 years
  • Located in 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
  • Has been part of the Envato Community for over 3 years
  • Has sold $1,000+ on Envato Market
  • Sells items exclusively on Envato Market
  • Located in 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
  • Has been part of the Envato Community for over 1 year
  • Has collected 10+ items on Envato Market
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/

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by