how can i get a startposition/location with LatLng. i do have a moving currentposition/location

E

elpaso

Guest
im trying to get the distance in meter from the startposition/location(past) to the moving currentposition/location(present). i do have the currentposition which works fine. but i cant get a startposition which should be fixed,saved, while i start the app with the startbutton. in fact, it is the same LatLng for startposition/location and currentposition/location. thank you.

ive tried to set a marker at the beginning. but i dont know how i can use it instead of the startposition to measure the distance.

mLocationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
super.onLocationResult(locationResult);

if (flag == 1) {
mGoogleMap.moveCamera(CameraUpdateFactory.newLatLng(
new LatLng(locationResult.getLastLocation().
getLatitude()
, locationResult.getLastLocation().
getLongitude())));
mGoogleMap.moveCamera(CameraUpdateFactory.
newLatLngZoom(new LatLng(locationResult.
getLastLocation().getLatitude()
, locationResult.getLastLocation().
getLongitude()), 19));
mGpsCurrentPosition = new LatLng(locationResult.
getLastLocation().getLatitude()
, locationResult.getLastLocation().
getLongitude());
mGpsStartPosition = new LatLng(locationResult.
getLastLocation().getLatitude()
, locationResult.getLastLocation().
getLongitude());
}
updateGps();
}
private void getLaufDistanz() {
Location laufStartPunkt = new Location("Start");
laufStartPunkt.setLatitude(mGpsStartPosition.latitude);
laufStartPunkt.setLongitude(mGpsCurrentPosition.longitude);
Location laufEndPunkt = new Location("Ende");
laufEndPunkt.setLatitude(mGpsCurrentPosition.latitude);
laufEndPunkt.setLongitude(mGpsCurrentPosition.longitude);
float laufDistanzInMeter = laufStartPunkt.distanceTo
(laufEndPunkt)/1000;
mTvMinProKm.setText("" + String.valueOf(laufDistanzInMeter));
}


i need a way to set the startposition with LatLng to measure the distance in meter.

Continue reading...
 
Top