Created
August 6, 2020 12:19
-
-
Save Dmuasya/3f2cf55525535f3fa44553d5f35da5cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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