On 11 July 2011 19:34, Nico Oudshoorn <[email protected]> wrote:
> This is from a site of mine. In an example that I tested, the outcome of
> $vanposlat was 52.133333. $zoekafstand = 15. The result of  $zoekafstand /
> (69 * 1.61) = 0,1350256. And surprise surprse $maxlat = 52.1350256???? So we
> lost the 0.133333???? However when I echo $vanposlat it = 52.133333, but if
> I do whatever calculation with it, you calculate only with 52??????
>
> Any suggestions?
>
> $url =
> "http://maps.googleapis.com/maps/api/geocode/xml?address=".urlencode($zoekpos)."&sensor=false";
>    $geo = new SimpleXMLElement(file_get_contents($url));
>    if ($geo->status == "OK") {
>     $vanposlat = $geo->result->geometry->location->lat;
>     $vanposlng = $geo->result->geometry->location->lng;
>     $maxlat = $vanposlat + ( $zoekafstand / (69 * 1.61)); // 69 miles per
> degree of latitude

I will guess that "$zoekafstand" is a search radius in kilometres, and
you're attempting to convert that into degrees via a figure in miles.

So you are using an approximate km/miles conversion, and then a
conversion from miles to degrees which only works in a north-south
direction (and again, is approximate).

And you're complaining that going through two approximations doesn't
produce an exact result. (0.000001deg is under 7cm E-W at 52N, and
around 11cm N-S)

Solution: don't use that method. Use the haversine method to calculate
distance server-side, or the API's methods client-side.

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

Reply via email to