0

Can i receive distance from a kml file? (Sorry for the bad language)

urlString.append("http://maps.google.com/maps?");
urlString.append("&saddr=");//from
urlString.append(src.getLatitudeE6()/1e6);urlString.append(","); 
urlString.append(src.getLongitudeE6()/1e6); 
urlString.append("&daddr=");//to 
urlString.append( dest.getLatitudeE6()/1e6); 
urlString.append(","); 
urlString.append( dest.getLongitudeE6()/1e6); 
urlString.append("&ie=UTF8&0&om=0&output=kml"); 
Zoltán
  • 21,321
  • 14
  • 93
  • 134
Qafqaz Qafqaz
  • 89
  • 1
  • 2
  • 8
  • Not sure about kml file...but i have already answered on how to find distance between two GeoPoints here..http://stackoverflow.com/questions/11294208/how-to-find-the-correct-distance-between-two-geopoints-in-map/11294271#11294271 – Vipul Jul 18 '12 at 11:49
  • @VipulShah but distance is more for example i know that distance will be no more 3-4 km but answer is 355775.4232.:( – Qafqaz Qafqaz Jul 18 '12 at 12:04

2 Answers2

0

This might be helpful to you

public static Double calculateDistance(Double lat1, Double lon1, Double lat2, Double lon2) {
    Double Radius = 6371.00;
    Double dLat = toRadians(lat2 - lat1);
    Double dLon = toRadians(lon2 - lon1);
    Double a = Math.sin(dLat / 2) * Math.sin(dLat / 2)
            + Math.cos(toRadians(lat1)) * Math.cos(toRadians(lat2))
            * Math.sin(dLon / 2) * Math.sin(dLon / 2);
    Double c = 2 * Math.asin(Math.sqrt(a));
    return Radius * c;
}

pass source latitude and longitude and destination latitude and longtitude as parameters

user
  • 323
  • 6
  • 11
0

The URL you have given was working properly for few months but now suddenly it stopped working and KML file is not being downloaded,instead path is showed under google maps,i guess it is in conflict of intrests with google's policy.

Santosh Kumar
  • 189
  • 1
  • 9
  • try using JSON object and parse it http://maps.google.com/maps?f=d&hl=en&saddr=vizianagaram,&daddr=vishakapatnam,&ie=UTF8&0&om=0&output=json – Santosh Kumar Oct 18 '12 at 12:52