Jump to content

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 ?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.