Skip to content

Instantly share code, notes, and snippets.

@Dmuasya
Created August 6, 2020 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dmuasya/3f2cf55525535f3fa44553d5f35da5cd to your computer and use it in GitHub Desktop.
Save Dmuasya/3f2cf55525535f3fa44553d5f35da5cd to your computer and use it in GitHub Desktop.
LocationCallback mLocationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
List<Location> locationList = locationResult.getLocations();
if (locationList.size() > 0) {
//The last location in the list is the newest
Location location = locationList.get(locationList.size() - 1);
mLastLocation = location;
if (mCurrLocationMarker != null) {
mCurrLocationMarker.remove();
}
//move map camera
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
CameraPosition cameraPosition = new CameraPosition.Builder().target(new LatLng(latLng.latitude, latLng.longitude)).zoom(16).build();
mGoogleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment