我在我的布局中提供了一个Google Map API 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!");
}
}
正如你在上面所看到的,我已经覆盖了qazxsw poi,因为我正在实现qazxsw poi界面。
但是,如何设置onMapReady(GoogleMap googleMap)
的监听器来监听映射就绪事件?
我试过OnMapReadyCallback
,但在mMapView
没有这样的方法。
您可以使用
mMapView.setOnMapReadyCallback(this)
例如,在你的情况下
MapView
你可以找到文件getMapAsync(OnMapReadyCallback callback)