2017-03-26 5 views
0

私のコードに2つのエラーがあります。次の行にエラーがあります。 onCreate()メソッドとgetMapAsync()を解決できません。キャッシュを無効にして再起動しましたが、それは役に立ちませんでした。この問題を解決するのを手伝ってください。onCreateまたはgetMapAsyncを解決できません

mapView.onCreate(savedInstanceState);

map = mapView.getMapAsync();

public class PlacesMapActivity extends Fragment implements OnMapReadyCallback { 
    private MapView mapView; 
    private GoogleMap map; 

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
         Bundle savedInstanceState) { 
    // Inflate the layout for this fragment 
    View v = inflater.inflate(R.layout.map_places, container, false); 
    // Gets the MapView from the XML layout and creates it 
    mapView = (MapView) v.findViewById(R.id.map); 
    mapView.onCreate(savedInstanceState); 

    // Gets to GoogleMap from the MapView and does initialization stuff 
    map = mapView.getMapAsync(); 
    map.getUiSettings().setMyLocationButtonEnabled(false); 
    map.setMyLocationEnabled(true); 

    // Needs to call MapsInitializer before doing any CameraUpdateFactory calls 
    try { 
     MapsInitializer.initialize(this.getActivity()); 
    } catch (GooglePlayServicesNotAvailableException e) { 
     e.printStackTrace(); 
    } 
    // Updates the location and zoom of the MapView 
    CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(43.1, -87.9), 10); 
    map.animateCamera(cameraUpdate); 

    return v; 

    } 

    @Override 
    public void onMapReady(GoogleMap googleMap) { 

    } 
} 

答えて

0

は何も返さないでください:map = mapView.getMapAsync();

使用:

mapView.getMapAsync(this); 

その後、onMapReady()内のMapオブジェクト

@Override 
public void onMapReady(GoogleMap googleMap) { 
    map= googleMap; 
} 
+0

を取得し、私はまだgetMapAsyncは(同じ問題..を持っています)解決することはできません..何らかの理由でそれもそれを認識しませんonCreate() –

+0

これをgradleに追加します: 'compile 'com.google.android.gms:play-services-maps:9.0.1' 'com.google.android.gms:play-services-location:9.0.1''をコンパイルして実行します。 – rafsanahmad007

+0

私はまだ同じ問題を抱えています.... –

関連する問題