Whenever the user selects this option, you use
LatLng initialLoc= mMap.getCameraPosition().target;
to get the supposedly starting location, which is wrong! mMap.getCameraPosition (). target returns the location that the camera points to. You should store lat long in onCreate() activity or somewhere else according to your other code, and then use the same in onOptionItemSelected() .
Btw you can combine scale and lat in one expression as follows.
LatLng coordinate = new LatLng(lat, lng);
UPDATE
I really don't know how accurate it would be or when it could be called. But you can use the same code
LatLng initialLoc= mMap.getCameraPosition().target;
Instead, call it once in onCreate() or onResume() , and then save it there. Then next time in optionsItemSelected() use these values. Although, why don't you just save the values ββthat you defined in your xml in java code and then use it?
source share