Hi all
I'm not sure this is possible with anything off the peg for CMSMS but thought I'd ask here in case anyone knows...!
I need to create a database of job adverts and let the user filter by distance from a (UK) postcode - I'm not sure how I would achieve this? The database of job entries I could build with LISE, but the postcode/distance calculator to filter the results I have no clue.
Is it achievable - anyone done it?
Thanks
Calculating distance from postcode and filtering results
-
johnboyuk1
- Forum Members

- Posts: 235
- Joined: Mon Nov 26, 2018 3:09 pm
Re: Calculating distance from postcode and filtering results
CompanyDirectory has this functionality when paired with a postcode module - I'm not sure what's available for the UK, but it's a starting point at least.
Not getting the answer you need? CMSMS support options
Re: Calculating distance from postcode and filtering results
I think there are two options:
1. Let some service do the calculations (Google Maps API or Open Street Maps API) for example.
They can calculate distances based on actual routes.
I don't think their services are free and it may be rather hard to implement, especially if you want to do a real-time filtering based on the user's address
2. Translate the user's address to a coordinates (longitude/latitude) and do some basic calculations on it to find the distance as the crow flies(?). I read that it's not easy to do an exact calculation but for a rather small country the deviation maybe within acceptable limits. Or perhaps there are php libraries which do better calculations for you.
The module DIGI3 mentioned uses geonames.org as a source and I see they offer downloads with postal code and lat/long coordinates
If you store the coordinates with the job entries/companies (this can be automated too) you may be able to filter the results based on a square area. It would probably need a custom db query too.
Either way it will involve some thinking and coding (or I don't know of the module doing all this for you)
1. Let some service do the calculations (Google Maps API or Open Street Maps API) for example.
They can calculate distances based on actual routes.
I don't think their services are free and it may be rather hard to implement, especially if you want to do a real-time filtering based on the user's address
2. Translate the user's address to a coordinates (longitude/latitude) and do some basic calculations on it to find the distance as the crow flies(?). I read that it's not easy to do an exact calculation but for a rather small country the deviation maybe within acceptable limits. Or perhaps there are php libraries which do better calculations for you.
The module DIGI3 mentioned uses geonames.org as a source and I see they offer downloads with postal code and lat/long coordinates
If you store the coordinates with the job entries/companies (this can be automated too) you may be able to filter the results based on a square area. It would probably need a custom db query too.
Either way it will involve some thinking and coding (or I don't know of the module doing all this for you)
-
johnboyuk1
- Forum Members

- Posts: 235
- Joined: Mon Nov 26, 2018 3:09 pm
Re: Calculating distance from postcode and filtering results
ok thanks guys... think the coding maybe beyond me! Was hoping there might be a module
Company directory I cant even get to work (have submitted bug report) so cant test that to see if I could twist it into what I need
Company directory I cant even get to work (have submitted bug report) so cant test that to see if I could twist it into what I need

