var geocoder, location1, location2;
function initialize() {
geocoder = new GClientGeocoder();
}
function showLocation(address) {
geocoder.getLocations(address, 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]};
calculateDistance();
}
});
}
function calculateDistance() {
try {
var glatlng1 = new GLatLng(location1.lat, location1.lon);
var brenham = new GLatLng(30.1513095, -96.3849029);
var college_station = new GLatLng(30.6100315, 96.3059892);
var miledistance1 = glatlng1.distanceFrom(brenham).toFixed(1);
var miledistance2 = glatlng1.distanceFrom(college_station).toFixed(1);
if (miledistance1 <= miledistance2) {
return (miledistance1 * .000621371192);
} else {
return (miledistance2 * .000621371192);
}
} catch (error) {
alert(error);
}
}
window.onload=function() { initialize(); }