On Mar 26, 8:28 am, Vishal <[email protected]> wrote:
> Hello,
>
> I am new to the Google API. I am doing a PoC for incorporating the
> Google Maps to my company's site. All I am trying to do is to GEOCODE
> and find out the distance between 2 addresses in US.
>
> I took 2 addresses determined their geocodes using the HTTP 
> Service:http://maps.google.com/maps/geo?q=????????&key=?????????&sensor=false...
>
> 2500 N State Road 7, Hollywood, 33021  (-80.2083941, 26.0322144)
> 590 W Flagler St, Miami, 33130  (-80.2042310, 25.7735980)
>
> Then I tried to find out the distance using GLatLng.distanceFrom()
> I wasnt sure whether the distance would be Driving Distance or over a
> straight line.

That will be a straight line

> However the addresses that I picked up are almost in
> straight line. Hence both the distances should be close to each
> other.
>
> If I get the directions on the Google Maps, I get a distance of 20
> miles, whereas I get 4918 meters using the GLatLng.distanceFrom()
> method. I have no clue why this is happening.

Get directions returns 19.6 mi for me:
http://www.geocodezip.com/example_geo2.asp?addr1=2500%20N%20State%20Road%207,%20Hollywood,%2033021&addr2=590%20W%20Flagler%20St,%20Miami,%2033130&geocode=1&geocode=2

javascript:GLog.write(new GLatLng(26.0322144, -80.2083941).distanceFrom
(new GLatLng(25.773598, -80.204231)))
Gives me: 28792.06404436075 meters.

While:
javascript:GLog.write(gdir.getDistance().meters)
Gives me: 31577 meters

It looks to me like you have the latitude and longitude backwards in
your code snippet.

  -- Larry

>
> Any help in this regard is appreciated.
>
> Below is the code I used:
>
>         <%-- Check whether the browser is compatible --%>
>         if (GBrowserIsCompatible())
>         {
>                 alert("Browser is compatible");
>                 var point1 = new GLatLng(-80.2083941, 26.0322144);
>                 var point2 = new GLatLng(-80.2042310, 25.7735980);
>                 var distance = point2.distanceFrom(point1);
>                 alert(distance);
>
>          }
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to