ikmyer Posted December 22, 2007 Share Posted December 22, 2007 I am working on a site and in one section it lists a bunch of addresses on a map... Any ideas of the best (or most effective/efficient) way to find addresses in the database that are surrounding a set point on the map. I have access to full address (address, city, state, zip) and Google maps Lat and Long coordinates. Like now do they do the the "Find x within 10 miles... 25 miles... 50 miles... ? Thanks! PS. i don't need the code... i can do that part... just need help with the idea/process. Quote Link to comment https://forums.phpfreaks.com/topic/82770-find-surrounding-addresses/ Share on other sites More sharing options...
revraz Posted December 22, 2007 Share Posted December 22, 2007 http://www.douglaskarr.com/2007/09/15/calculate-distance/ Quote Link to comment https://forums.phpfreaks.com/topic/82770-find-surrounding-addresses/#findComment-420957 Share on other sites More sharing options...
Northern Flame Posted December 22, 2007 Share Posted December 22, 2007 Good post revraz! I just went through that article and tried out the script and its very helpful Quote Link to comment https://forums.phpfreaks.com/topic/82770-find-surrounding-addresses/#findComment-420960 Share on other sites More sharing options...
ikmyer Posted December 22, 2007 Author Share Posted December 22, 2007 thanks for the link revraz... it looks promising. Quote Link to comment https://forums.phpfreaks.com/topic/82770-find-surrounding-addresses/#findComment-421389 Share on other sites More sharing options...
ikmyer Posted December 23, 2007 Author Share Posted December 23, 2007 ok... so i got the function working normal. When i try to test the sql i get the following... SELECT * , (((acos( sin( ( 38.502147 * pi( ) /180 ) ) * sin( ( `g_lat` * pi( ) /180 ) ) + cos( ( 38.502147 * pi( ) /180 ) ) * cos( ( `g_lat` * pi( ) /180 ) ) * cos( ((-117.022694 - `g_long`) * pi( ) /180 )))) *180 / pi( )) *60 * 1.1515 ) AS distance FROM users_maps WHERE distance < 2 MySQL said: Documentation #1054 - Unknown column 'distance' in 'where clause' If i take out the "WHERE distance < 2" it just returns all results with a distance field which looks to be correct. any ideas ? Quote Link to comment https://forums.phpfreaks.com/topic/82770-find-surrounding-addresses/#findComment-421411 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.