2016-06-09 70 views
0

我幾乎沒有開始使用亞馬遜地圖V2,它一直在努力工作。現在我試圖在我的代碼中參考地圖,作爲亞馬遜網站的解釋(https://developer.amazon.com/public/apis/experience/maps/docs-v2/displaying-an-interactive-map-with-the-amazon-maps-api-v2)。無法解析符號.getMapAsync

問題是,android studio不能識別「getMapAsync」方法。

這裏是我的代碼:

mMapFragment = (MapFragment) getFragmentManager().findFragmentById(
      R.id.mapFragment); 

    // Call .getMapAsync() and pass it an object that implements 
    // the OnMapReadyCallback interface. 


    mMapFragment.getMapAsync(new OnMapReadyCallback() { 
     @Override 
     public void onMapReady(AmazonMap amazonMap) { 
      // This method is called when the map is ready. The AmazonMap 
      // object provided to this method will never be null. 

      // Use the map reference to set UI settings and other options. 
      amazonMap.getUiSettings().setZoomControlsEnabled(true); 
      amazonMap.setTrafficEnabled(true); 
     } 
    }); 
在我的build.gradle(項目)

我有這樣的:

allprojects { 
    repositories { 
     jcenter() 
     mavenLocal() 
    } 
} 

,並在我的build.gradle(模塊)我有這樣的:

dependencies { 
    ...other unrelated dependencies 
    compile ('com.amazon.android:amazon-maps-api:2.0') 
} 

在此先感謝你們。

回答

0

嘿,夥計們,我發現我的錯誤。這很簡單。我需要使用SupportMapFragment類而不是MapFragment,並將片段導入更改爲「android.support.v4.app.Fragment」。我仍然不確定爲什麼我不能像網站中所解釋的那樣使用MapFragment。