Android Maps PolygonOptions Lat and Long value in km

89 views Asked by At

I'm trying to draw a square in the map in which the center is the location of the user. Each type of user have different value of kilometers. All of that is clear to me and drawing polygon is not a problem.

The problem is that I dont know the value of latitude and longitude converted to kilometers.

My question is what is the value of 1 kilometer converted into latitude. is it 0.001 or something like that. And are the converted value different in longitude

2

There are 2 answers

0
amalBit On BEST ANSWER

It varies as the earth is not flat but a sphere:

  • Each degree of latitude is approximately 69 miles (111 kilometers) apart.
  • At the equator, the distance is 68.703 miles (110.567 kilometers).
  • At the Tropic of Cancer and Tropic of Capricorn (23.5° north and south), the distance is 68.94 miles (110.948 kilometers).
  • At each of the poles, the distance is 69.407 miles (111.699 kilometers).

More here.

2
Mrinmoy On
public float distance (float lat_a, float lng_a, float lat_b, float lng_b ) 
{
    double earthRadius = 3958.75;
    double latDiff = Math.toRadians(lat_b-lat_a);
    double lngDiff = Math.toRadians(lng_b-lng_a);
    double a = Math.sin(latDiff /2) * Math.sin(latDiff /2) +
    Math.cos(Math.toRadians(lat_a)) * Math.cos(Math.toRadians(lat_b)) *
    Math.sin(lngDiff /2) * Math.sin(lngDiff /2);
    double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
    double distance = earthRadius * c;

    int meterConversion = 1609;

    return new Float(distance * meterConversion).floatValue();
}

Try this code it will provide distance in Km from lat lan