If you are looking to find all points in your DB from a fixed point then it is unrealistic to do so on the basis of a circle but a square around the point is possible
I use a technique to solve a similar problem by use of a SQL query on the database. You need to implement the Haversine formula (Google it) to calculate the distance converting coordinates into actual miles or kms as the earth is a sphere so the lat & lon cannot be simply "subtracted from each other" I have done this with the following formula where $lat = latitude of centre point (i.e. the petrol station) $lon = longitude of centre point (i.e. the petrol station) $distance = "radius" of square (size of box around point) in miles Assuming longitude and latitude are fields in a table called company repesenting the coordinates of all the locations in the table (This formula works in miles not kms but the conversion is easy enough) SELECT *,((ACOS(SIN( $lat * PI() / 180) * SIN(latitude * PI() / 180) + COS($lat * PI() / 180) * COS(latitude * PI() / 180) * COS(($lon - longitude) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS distance FROM company HAVING distance<= 1 Hope that helps Brian Direct Uk Marketing On Feb 16, 7:03 pm, "Ignacio Guarinos" <[email protected]> wrote: > Sorry, I'm explaining myself poorly. > I have a database with several lat&longs stored in it, let's say they > correspond to petrol stations (just an example) and then the user > introduces his location (40.4167413, -3.7032498) I would like to know > wich calculation should I make to give him the info of all the lat&longs > in my DB that can be found in a radius of 1km taking his position as the > center. > So it must be something like this: > All the lats between X and Y. > And all the longs between X and Y. > What I don't know is the correspondency between this (40.4167413, > -3.7032498) and kilometers if it exists. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
