2016-09-18 5 views
0

ここはGoogle Mapプロジェクト用に作成したコードです。しかし、それは行番号のエラーを促しています。 271 getMapAsync()で。SupportMapFragmentのgetMapAsync(OnMapReadyCallback)を()に適用できません

あなたはこのようなgetMapAsync()メソッドに "新しいOnMapReadyCallbackを()" を渡す必要があり
private void setUpMap(double lat,double lon) { 
    // 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)).getMapAsync(); 
     // Check if we were successful in obtaining the map. 
     if (mMap != null) { 
      mMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(lat, lon))); 
      mMap.animateCamera(CameraUpdateFactory.zoomTo(16.0f)); 
      if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) 
        == PackageManager.PERMISSION_GRANTED) { 
       mMap.setMyLocationEnabled(true); 
      mMap.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() { 
       @Override 
       public void onMapLongClick(LatLng latLng) { 
        try { 
         new GetPlacesAsyncTask().execute(latLng.latitude, latLng.longitude); 

        } catch (Exception ex) { 
         Toast.makeText(getApplicationContext(), ex.getMessage(), Toast.LENGTH_LONG).show(); 
        } 
       } 
      }); 

     } 
    } 
}} 

答えて

1

: - getMapAsync(新しいOnMapReadyCallback(){})

+1

が同じことをしようとしましたが、それはありますOnMapReadyCallback(){})のポイントにエラーが表示されます。詳細に記述してください。 – Chandu

+0

このように書く必要があります: - mMap =((SupportMapFragment)getSupportFragmentManager()。findFragmentById(R.id.map)); mMap.getMapAsync(新しいOnMapReadyCallback(){ @Override公共ボイドonMapReady(Googleマップマップ){ }})。 –

+0

これはうまくいきません。他のソリューション投稿がある場合はこちら – Chandu

関連する問題