如何将OnMapReadyCallback设置为我的MapView实例?
问题描述:
我有一个谷歌地图API在我的布局提供MapView
:如何将OnMapReadyCallback设置为我的MapView实例?
<com.google.android.gms.maps.MapView xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map_view"
...
/>
在我的片段,我实现了OnMapReadyCallback
:
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!");
}
}
正如你可以在上面看到,我已经重写了onMapReady(GoogleMap googleMap)
因为我实施OnMapReadyCallback
界面。
但是,如何设置mMapView
的听众收听地图准备事件?
我试过mMapView.setOnMapReadyCallback(this)
但MapView
中没有这样的方法。