Get the distance between two locations in android?
i need to get distance between two location, but i need to get distance like blue line in the picture. I try next: public double getDistance(LatLng LatLng1, LatLng LatLng2) { double distance = 0; Location locationA = new Location("A"); locationA.setLatitude(LatLng1.latitude); locationA.setLongitude(LatLng1.longitude); Location locationB = new Location("B"); locationB.setLatitude(LatLng2.latitude); locationB.setLongitude(LatLng2.longitude); distance = locationA.distanceTo(locationB); return distance; } but i get red line distance. Use the Google Maps Directions API . You'll need to request the