Building a recruitment website - Help with location searching

Hi,

I am still new to Wappler and I am trying to build a small recruitment website / job board.

I would like users to be able to search by category / job title etc - I think I have this bit thanks to some of the hyperbytes tutorials.

I would also ideally like them to be able to search by location. I could do this with options they select from but the ideal solution is to be able to do a radius search around a UK post-code. If this is something fairly simple (without loads of custom code) and there is a guide / working example I can look at, please point me in the right direction. If not I can try broader county / city searches instead.

Thanks!

I have a property site which does this by geocoding.

Basically each property is geocoded with it’s latitude and longitude (there is a tutorial re that on the forum already)

The user then picks a search location and a radius from that point which again is geocoded (the site actually uses an ajax style dropdown for this bit but that doesn’t have to be the case)

I then have written a custom query which searches for all properties within the selected radius of the search location based on the Haversine formula

I am a bit out of my depth here but if a user adds a job I could then get the long/lat from something like this https://postcodes.io/ and store it in my DB then when someone puts in their postcode to run a search I would need to get the long/lat again and use a custom query to pull out the relevant jobs. Is that similar to how you did it? Haversine looks useful!

Something like this could be useful too to save relying on an external API https://www.freemaptools.com/download-uk-postcode-lat-lng.htm

You can try with google maps API.

The Google map api method of geocoding is discussed here. Title is mass geocoding but its basically a single geocode in a delayed loop.

I think @Hyperbytes will be getting a pumpkin spice coffee in the future… :slight_smile:

1 Like

When i implemented this it was pre custom queries so it is a hard coded haversine search but i will re-do it in wappler now that we can and publish it, maybe a “how to” coming here i think :grinning:

1 Like

I can expand on this more if needed and do a full “how to” from end to end or even a future webinar but here is a quick summary as I am very pushed for time at present

In this example I have a table called agents.
Each agent’s office has been pre geocoded into fields “lat” and “lng

I wish to find all agents within a given radius of a fixed point

So our fixed point is geocoded as a lat and lng (see post re mass geocoding for process) and the radius for search entered

we send those parameters as $_GET variables (could also be $_POST from a form or calculated within the server action) ) but for this example say $_GET.baselat, $_GET.baselng and $_GET.radius as the lat and lng of the fixed point and the desired search radius

I wish to return all agent info and the distance from the fixed point from a query

This involves a formula which is set out below, in this base returning all data (select *) and a calculated field DistanceFrom which is the distance from the centre point in a straight line)

NOTE 1 This is set up for UK miles, will need to be corrected for Km
NOTE 2 This is distance in a straight line, not via road which needs a different approach (i believe i have already posted that solution previously)

This example shows all within 10 UK miles of the city of Leeds, UK

2 Likes

Looking forward to having a go at this! For other people who might find it useful (I was trying to work out where your 69 was coming from):

In a degree of latitude there are:

  • Kilometers (111.045)
  • Miles (69)
  • Nautical miles (60)
1 Like

Glad you worked it out, i wrote this query in around 2007 and had forgotten that