I were using the store locator tutorial suggested by Larry which seemed to be what I needed. It is using the Haversine formula to calculate the addresses within a specific distance.
To get out all the addresses within 5 km the SQL-command after the tutorial looks like this (in PHP): $radius=5; SELECT id,lat,lng, (6371*acos(cos(radians($lat))*cos(radians(lat))*cos(radians(lng)- radians($lng))+sin(radians($lat))*sin(radians(lat)))) AS distance FROM addresses HAVING distance<$radius ORDER BY distance LIMIT 50 $lat and $lng is the geocoded location from the origin address. When I look at the map and using Google's scaleControl to compare it with the results shown within 5 km, also addresses were shown which are a lot farther away than 5km. Does anybody know how I can fix that problem or what's wrong on the formula? On 21 Sep., 16:06, Rossko <[email protected]> wrote: > > If you'd rather have him use Haversines formula, why not quote > > it here. > > He can use what he likes, when properly informed. It's not difficult > to find discussion of Haversine in the language and context of choice > for any interested person. > > > Otherwise, for distances under a few hundred miles (other > > than at Latitude 90 or -90) my formula should work (assume latitude is > > "y" and longitude is "x"). > > For moderate latitudes, error could be in the order of 30%, and will > apply to distances of miles or metres. That might be fine for the > orginal poster, so long as they understand the limitations of using > degrees as a form of distance measurement away from the equator. > > For the original poster, have a look at some of these > http://www.google.com/search?q=lat+long+distance > just calculate the distance between two points, convert it to miles or > metres or whatever you want, and compare it with the search > requirement. -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" 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-js-api-v3?hl=en.
