2016-08-24 23 views
1
private void setUpMapIfNeeded() { 
    // Do a null check to confirm that we have not already instantiated the map. 
    if (mMap == null) { 
     // Try to obtain the map from the SupportMapFragment. 
     mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)) 
       .getMap(); 
     // Check if we were successful in obtaining the map. 
     if (mMap != null) { 
      setUpMap(); 
     } 
    } 
} 

「出於某種奇怪的原因,說.getmap()的區域不起作用,任何人都可以提供幫助。」試圖製作地圖

回答

0

嘗試移除.getmap()部分並改爲放置getMapAsync()。

private void setUpMapIfNeeded() { 
    // Do a null check to confirm that we have not already instantiated the map. 
    if (mMap == null) { 
     // Try to obtain the map from the SupportMapFragment. 
     mMap =((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map)); 
     mapFragment.getMapAsync(this); 
     // Check if we were successful in obtaining the map. 
     if (mMap != null) { 
      setUpMap(); 
     } 
    } 
} 
+0

感謝您的幫助,但它的說法theat(This)是編碼錯誤。 –