2017-12-18 2 views
-1

나는 구글지도 API 내 레이아웃에 MapView을 제공 한 : 위에서 볼 수 있듯이 나는 때문에, 나는 onMapReady(GoogleMap googleMap)를 오버라이드 (override) 한OnMapReadyCallback을 내 MapView 인스턴스에 설정하는 방법은 무엇입니까?

public class MyFragment extends Fragment implements OnMapReadyCallback { 

    // onCreate, onCreateView are not showing here but I have them. 

    @BindView(R.id.map_view) 
    MapView mMapView; 

    // this is the method form the interface I am implementing. 
    @Override 
    public void onMapReady(GoogleMap googleMap) { 
     Log.d("MyFragment", "map ready!"); 
    } 
} 

: 내 조각에서

<com.google.android.gms.maps.MapView xmlns:map="http://schemas.android.com/apk/res-auto" 
      android:id="@+id/map_view" 
... 
/> 

, 나는 OnMapReadyCallback를 구현 OnMapReadyCallback 인터페이스를 구현합니다.

하지만지도 준비 이벤트 수신을 위해 mMapView 수신기를 설정하려면 어떻게해야합니까?

mMapView.setOnMapReadyCallback(this)을 시도했지만 MapView에는 그러한 방법이 없습니다.

답변

0

당신은

getMapAsync(OnMapReadyCallback callback) 

는 예, 귀하의 경우

mMapView.getMapAsync(this); 

을 당신이 문서 here

을 찾을 수 있습니다 사용할 수 있습니다
관련 문제