Finally: a bright moment. the "distance" method has property "kilometers",
"miles" etc. according to the manual.
So:
var g1 = new YGeoPoint(52.4264895, 4.8389139);
var g2 = new YGeoPoint(52.3539378, 4.9302562);
var d = g1.distance(g2);
alert(d.kilometers);
This works, but is SO WRONG!!! According to the lon/lat's of the two geopoints
(which I retrieved by using:
http://developer.yahoo.com/maps/rest/V1/geocode.html), the distance from my
office to HQ is about 10 kilometers, while in fact it's almost 20 (about 19.5)!
Am I doing something wrong here (probably!).
If so, can anyone point me in the right direction, cause it looks like the
Haversine formula was used, which is never too accurate.
Too bad this forum does not seem to be a very active one, and pretty sure that
Yahoo will never respond themselves....
--- In yws-maps-ajax@yahoogroups.com, "connectcasenl" <cees@...> wrote:
>
> So far, I came up with:
>
> var g1 = new YGeoPoint(52.426520,4.839082);
> var g2 = new YGeoPoint(52.354187,4.929902);
> var d = g1.distance(g2);
>
> I just want the var d to be outputted, but don't know how. It keeps telling me
it is an object.....
>
> --- In yws-maps-ajax@yahoogroups.com, "connectcasenl" <cees@> wrote:
> >
> > Hi there,
> >
> > anyone know if it's possible to create a distance calculator with the Ajax
API? Been searching the Developer Network site all night long, but I could only
find that it's possible with the AS3 API.
> >
> > Regarding the Ajax API, there is a YMapDistance-constructor, but that seems
to be some sort of convertor....
> >
> > What I want is basically: enter two adresses, calculate distance and output
that in a div. Preferrably no loading of any (graphical) maps.....
> >
> > Thanks for any points into the right directioN!
> >
>