I want to replace the deprecated getMap
Method with getMapAsync
, but I didn't use MapFragment
but GoogleMap
like this:
private GoogleMap googleMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
try {
if(googleMap == null) {
googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
}
googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
googleMap.setMyLocationEnabled(true);
googleMap.setTrafficEnabled(true);
googleMap.setIndoorEnabled(true);
googleMap.setBuildingsEnabled(true);
googleMap.getUiSettings().setZoomControlsEnabled(true);
If I replace the googleMap
with MapFragment
like this I'm not able anymore to setMapType
and so on. So how can I change to getMapAsync
in my case?
MapFragment mapFragment = (MapFragment) getFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
question from:
https://stackoverflow.com/questions/31371865/replace-getmap-with-getmapasync 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…