Making a Location object in Android with latitude and longitude values

后端 未结 3 1064
南笙
南笙 2020-12-07 16:12

I have a program in which latitude and longitude values of a location are stored in a database, which I download.

I want to get the distance between these coordinat

3条回答
  •  广开言路
    2020-12-07 16:37

    Assuming that you already have a location object with you current location.

    Location targetLocation = new Location("");//provider name is unnecessary
    targetLocation.setLatitude(0.0d);//your coords of course
    targetLocation.setLongitude(0.0d);
    
    float distanceInMeters =  targetLocation.distanceTo(myLocation);
    

提交回复
热议问题