I'm using the store locator tutorial and the haversine based query I
took from there isn't calculating the correct distance, thereby giving
incorrect results.  I know people have gotten this working, so I
assume it's on my end, but I just can't see where.

I picked a random spot in San Francisco and retrieved the coordinates:
(37.763116, -122.432327)

You can confirm that this is in San Francisco here (http://
maps.google.com/maps?
f=q&source=s_q&hl=en&geocode=&q=37.763116,+-122.432327&sll=37.0625,-95.677068&sspn=45.688268,93.076172&ie=UTF8&z=16)

I've added a handful of points to my markers table and run a simple
script that outputs the sql query and loops through the results
echoing the returned rows.  You can see below that the distances are
way off (if the Mountain View distances aren't obvious, the SF
distance of 32 miles should be a good indicator that something is
awry):

SELECT address, name, lat, lng, ( 3959 * acos( cos( radians
('37.763116') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians
('-122.432327') ) + sin( radians('37.763116') ) * sin( radians
( lat ) ) ) ) AS distance FROM markers HAVING distance < '100' ORDER
BY distance LIMIT 0 , 3

Array (
 [address] => 570 N Shoreline Blvd, Mountain View, CA
 [name] => Round Table Pizza: Mountain View
 [lat] => 37.402653
 [lng] => -122.079353
 [distance] => 31.52676679158 )

Array (
[address] => 191 Castro St, Mountain View, CA
[name] => Kapp's Pizza Bar & Grill
[lat] => 37.393887
[lng] => -122.078918
[distance] => 32.022531165643 )

Array (
[address] => 517 Castro St, San Francisco, CA
[name] => Sausage Factory Inc
[lat] => 37.389580
[lng] => -122.081467
[distance] => 32.176938769486 )

Any ideas?

--

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=.


Reply via email to