Jump to content

Find Surrounding Addresses


ikmyer

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/82770-find-surrounding-addresses/
Share on other sites

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 ?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.