Here is my code. Can u plz tell me what to be done to calculate the
distance between two UK postcodes....

<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps JavaScript API Example:    Extraction of Geocoding
Data</title>
<script src="http://maps.google.com/maps?
file=api&amp;v=2&amp;sensor=true_or_false&amp;key=ABQIAAAAknrjiPDLCmCgSuyPFdOPaxQwicZ7vfoQ-
_TOjhQ1BwvmIUNaNxR38KtVNyQnGVmZBNUTIMpv4iGQug" type="text/
javascript"></script>
<!-- According to the Google Maps API Terms of Service you are
required display a Google map when using the Google Maps API. see:
http://code.google.com/apis/maps/terms.html -->
<script type="text/javascript">

var geocoder, location1, location2;
function initialize() {
geocoder = new GClientGeocoder();
}
function showLocation() {
geocoder.getLocations(document.forms[0].address1.value, function
(response) {
if (!response || response.Status.code != 200)
{
alert("Sorry, we were unable to geocode the first
address");
}
else
{
location1 = {lat: response.Placemark[0].Point.coordinates[1], lon:
response.Placemark[0].Point.coordinates[0], address: response.Placemark
[0].address};
geocoder.getLocations(document.forms[0].address2.value, function
(response) {
if (!response || response.Status.code != 200)
{
alert("Sorry, we were unable to geocode the second
address");
}
else

{
location2 = {lat: response.Placemark[0].Point.coordinates[1], lon:
response.Placemark[0].Point.coordinates[0], address: response.Placemark
[0].address};
calculateDistance();
}
});
}

});
}

function calculateDistance()
{
try
{
var glatlng1 = new GLatLng(location1.lat, location1.lon);
var glatlng2 = new GLatLng(location2.lat, location2.lon);
var miledistance = glatlng1.distanceFrom(glatlng2, 3959).toFixed(1);
var kmdistance = (miledistance * 1.609344).toFixed(1);
document.getElementById('results').innerHTML = '<strong>Address 1: </
strong>' + location1.address + '<br /><strong>Address 2: </strong>' +
location2.address + '<br /><strong>Distance: </strong>' + miledistance
+ ' miles (or ' + kmdistance + ' kilometers)';
}
catch (error)
{
alert(error);
}
}
</script>
</head>
<body onload="initialize()">

<form action="#" onsubmit="showLocation(); return false;">
<p>

<input type="text" name="address1" value="Address 1"
class="address_input" size="40" />
<input type="text" name="address2" value="Address 2"
class="address_input" size="40" />
<input type="submit" name="find" value="Search" />

</p>
</form>
<p id="results"></p>
</body>
</html>

On Jun 16, 4:28 pm, Barry Hunter <[email protected]> wrote:
> On 16/06/2009, JavaJive <[email protected]> wrote:
>
>
>
>
>
>
>
> >  On Jun 16, 1:51 pm, Barry Hunter <[email protected]> wrote:
>
> >  > > But equally:
> >  > >  1)      It doesn't say that you can't.
>
> >  > Quote:
> >  > "1.1 ..... You are allowed to use the API only to display, and to make
> >  > such uses as are necessary for You to display, Google Search Results
> >  > on your Property. ..."
>
> >  > pretty explicit....
>
> > ... as allowing, as I read it.  'your Property' in this case being a
> >  map, how else can it possibly be imagined that one might display a
> >  result returned as a Lat/Lng?
>
> >  > And as responsible users we should activily work to stay within the
> >  > restrictions, otherwise a very useful facility (for centering during a
> >  > 'search' session) could and will be withdrawn.
>
> > Yes, I agree, I'm just not convinced that I'm breaking the spirit let
> >  alone the letter of the T&C.
>
> *Your* use of the API may well be ok, I havent seen your page to
> really tell. But you appear to be promoting using the LocalSearch API
> in a way its not intended. (as the question of the thread was not
> about simply centering a map)
>
>
>
> --
> Barry
>
> -www.nearby.org.uk-www.geograph.org.uk-- Hide quoted text -
>
> - Show quoted text -

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