I am working on a project (specifically marketplace based, a bit like gumtree) whose content will heavily rely on the location of it’s users and the proximity between each other. The plan is to launch the website in the UK first.
Can I get some advice on how best to go about creating a system which dynamically alters the content displayed according to the location of the user? I don’t want it to be as simple or linear as just display content relevant to one particular location only, but within a changeable mile radius.
I have a feeling this will have something to do with UK post code decoding, any ideas?
Get the location of the user.
1, IP address - (not very accurate [google]maxmind geoip[/google])
2, geo-enabled mobile device - (user may not have one)
3 they told their browser where it is located (may have mulitple browsers, throw out cookies, change settings and so on)
4, ask them (they lie, they move, they may not be there at the moment, they cannot type their own postcodes correctly etc)
Maybe turn that postcode or a geopoint.
Problem 2
Decide if you are going to :
1, keep the entire worlds postcodes on your machine to query (thats expensive, how do you keep it up to date?)
2, use an api of postcodes (what if it is not reachable?)
User tells you they are at ‘B12 1AA’ (optionally look it up and find out that is 52.46 -1.88) and you store that info.
Then EITHER query your db and use one of the algos you will find in the posts below to “find nearest” with 52.24, -1.88.
OR find users with the same ‘postcode = “B12 1AA”’,
OR find users with similar ‘postcode LIKE “B12 1%”’
OR find users a bit further with ‘postcode LIKE “B12%”’
OR get a bit fancier and work out for each postcode area such as B12 1** that the immediate neighbours are B12 2, B12 5, B11 8 and so on…