查询MySQL数据库以使用PHP显示英国邮政编码的某个半径范围内的属性

I have a MySQL table containing a list of properties in the UK. The table contains the full address of each property including the post code. I need to be able to query the database to show all properties within a certain radius (e.g. 3 miles) of a given post code.

I've searched SO and couldn't find a similar question.

Research on Google seems to suggest I need to use Google Maps but I can't find any material to get me going. I don't need to display the results on a map at this stage, a simple list of the properties will suffice.

I'm not asking for someone to code this for me (although that would be nice!), I'm just after a point in the right direction.

Thanks.

If your properties are already accounted on the Google Server the Google Places API would be able to retrieve them. You just need to set the radius of 3 miles as parameter.

https://maps.googleapis.com/maps/api/place/nearbysearch/output?parameters

More details related to the parameter passed can be found in this official documentation.

If these places are not accounted in Google than they wont be displayed after requesting this REST API. Then you have to follow the standard procedure of:

  • Creating a query of fetching the requesting the address in within 3 miles with given postal address. Select address from table where radius=3 & postalCode=xxxxx;
  • When you have the address convert them into Lat/Lng using Geocoder API.
  • Finally display them on Google Maps.

Hope this helps!!