Good afternoon.
I am using the Google Maps API which I must trace from any location and trace a line to my geolocation.
This I have already accomplished, but the problem is that when I perform the calculation using SphericalUtilities.computerdistanceBetween O Location.distanceTo()
it gives me an amount that does not come close to the correct or real distance.
For example: 1.2112E7 instead of 1,200m
Code (DistanceTo):
Location location = new Location("A");
location.setLatitude(location.getLatitude());
location.setLongitude(location.getLongitude());
Location locationb = new Location("B");
locationb.setLatitude(latLng.latitude);
locationb.setLongitude(latLng.longitude);
location.distanceTo(locationb);
String distancia = locationb.toString();
Toast.makeText(MapsActivity.this, distancia, Toast.LENGTH_SHORT).show();
Code (SphericalUtil):
Double distancia = SphericalUtil.computeDistanceBetween(latLng,latLng);
String distanciaC = distancia.toString();
Toast.makeText(MapsActivity.this, distanciaC, Toast.LENGTH_SHORT).show();
I know what the code does is that it turns the world around and gets a greater distance, but I do not know how to correct it