Я хочу добавить маркер моего текущего местоположения на MapView, но маркер не отображается, код выглядит так:
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this.getContext());
........
@Override
public void onMapReady(GoogleMap googleMap) {
MapsInitializer.initialize(getContext());
googleMapObj = googleMap;
googleMapObj.setMapType(GoogleMap.MAP_TYPE_NORMAL);
getMyLastLocation();
moveCamera.....
googleMapObj.setMyLocationEnabled(true);
}
private void getMyLastLocation(){
mFusedLocationClient.getLastLocation().addOnCompleteListener(new OnCompleteListener<Location>() {
@Override
public void onComplete(@NonNull Task<Location> task) {
if(task.isSuccessful()){
Location location = task.getResult();
geopoint = new GeoPoint(location.getLatitude(),location.getLongitude());
Log.d(TAG, geopoint.toString());
googleMapObj.addMarker(new MarkerOptions()
.position(new LatLng(geopoint.getLongitude(),geopoint.getLongitude()))
.title("My Location"));
}
}
});
}
Мне интересно, почему Маркер не отображается на MapView