I have a google maps activity and i want to get the location of the user,
but the function i want to use: getMyLocation()
is deprecated.
Here is my piece of code:
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// This function is deprecated
// What is the new function?
mMap.getMyLocation();
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
Quoting the documentation:
use com.google.android.gms.location.FusedLocationProviderApi instead. FusedLocationProviderApi provides improved location finding and power usage and is used by the "My Location" blue dot. See the MyLocationDemoActivity in the sample applications folder for example example code, or the Location Developer Guide.
IOW, there is no replacement method. Instead, you use other APIs for finding the user's location.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With