Get the distance between two geo points

后端 未结 9 596
旧巷少年郎
旧巷少年郎 2020-11-27 09:11

I want to make an app which checks the nearest place where a user is. I can easily get the location of the user and I have already a list of places with latitude and longitu

9条回答
  •  孤城傲影
    2020-11-27 09:53

    private float getDistance(double lat1, double lon1, double lat2, double lon2) {
            float[] distance = new float[2];
            Location.distanceBetween(lat1, lon1, lat2, lon2, distance);
            return distance[0];
        }
    

提交回复
热议问题