PHP/MySQL: Select locations close to a given location from DB

后端 未结 7 1557
隐瞒了意图╮
隐瞒了意图╮ 2021-02-02 03:15

In PHP, I have the following code for calculating the distance between two locations:



        
7条回答
  •  悲&欢浪女
    2021-02-02 03:51

    Why don't you use MySQL's geospatial features...? No, just kidding.

    If the 200 records are actual places like towns, etc then as an alternative could you use GeoNames' API?

    The following webservice will provide the 10 closest locations to the lat and lng provided:

    http://ws.geonames.org/findNearby?lat=47.3&lng=9

    Source: http://www.geonames.org/export/web-services.html#findNearbyPlaceName

    Full list: http://www.geonames.org/export/ws-overview.html

提交回复
热议问题