2017-02-10 13 views
2

文法上の誤りがあれば、それをどうぞ。 私は断片の中でGoogleマップを見るためにチュートリアルに従いましたが、何かが間違っていました。メソッド「getMapAsync」を解決できません

これは断片で引っ掛けて、私のファイルの.javaです:

public class MapFragment extends Fragment implements OnMapReadyCallback{ 
@Nullable 
@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
         Bundle savedInstanceState) { 
    // Inflate the layout for this fragment 
    return inflater.inflate(R.layout.fragment_map, container, false); 

} 

@Override 
public void onViewCreated(View view, Bundle savedInstanceState) { 
    super.onViewCreated(view, savedInstanceState); 

    MapFragment fragment = (MapFragment)getChildFragmentManager().findFragmentById(R.id.map); 
    fragment.getMapAsync(this); //Here i get the error 
} 

@Override 
public void onMapReady(GoogleMap googleMap) { 

} 

}

これは、レイアウトフラグメントである:

<fragment 
    android:id="@+id/map" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    class="com.google.android.gms.maps.MapFragment"></fragment> 

どうしたの?

ありがとうございました!

+0

正確に何が間違っていますか? –

+0

私はマップを開くと、このエラーが表示されます:http://pastebin.com/RZehk7XC – RvGPredator

答えて

3

あなたは、むしろXMLでMapFragment
断片

SupportMapFragment fragment = (SupportMapFragment)getChildFragmentManager().findFragmentById(R.id.map); 
fragment.getMapAsync(this); 
0

ディーパックGoyal氏で

<fragment 
    android:id="@+id/map" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    class="com.google.android.gms.maps.SupportMapFragment"></fragment> 

よりもSupportMapFragmentを使用する必要があなたに感謝し、今、私は別の問題を抱えている:

E/b: Authentication failed on the server. E/Google Maps Android API: Authorization failure. Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map. E/Google Maps Android API: In the Google Developer Console (https://console.developers.google.com) Ensure that the "Google Maps Android API v2" is enabled. Ensure that the following Android Key exists: API Key: (My key, yes it exist) Android Application (;): 6E:F7:62:8E:54:D0:69:E9:6B:CF:0C:F1:1B:29:7F:F6:F0:13:02:AB;

+0

このSHA1 '6E:F7:62:8E:54:D0:69:E9: 6B:CF:0C:F1:1B:29:7F:F6:F0:13:02:AB; https://developers.google.com/maps/documentation/android-api/start –

+0

https://developers.google.com/maps/documentation/android-api/signup –

+0

のドキュメントを読んだが、何かが変更された。 ScreenShot:http://i.imgur.com/trQ8M8h.png?1私はイタリア語なので、このスクリーンショットでは、イタリア語の翻訳 – RvGPredator

関連する問題