小编par*_*rse的帖子

测量事件监听器上的MapFragment

我正在使用MapFragment,我的活动布局是:

<fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/actionbar" />
Run Code Online (Sandbox Code Playgroud)

如果我想使用移动地图相机CameraUpdateFactory.newLatLngBounds(LatLngBounds, padding) 我得到此错误:

Map size can't be 0. Most likely, layout has not yet occured for the map view.  Either wait until layout has occurred or use newLatLngBounds(LatLngBounds, int, int, int) which allows you to specify the map's dimensions.
Run Code Online (Sandbox Code Playgroud)

如果地图已经测量,是否有事件监听器?

EDIT1:@raz这是我检索地图片段的代码:

if (googleMap == null) {
            googleMap = ((MapFragment) getFragmentManager().findFragmentById(
                    R.id.map)).getMap();
}
Run Code Online (Sandbox Code Playgroud)

android google-maps

2
推荐指数
1
解决办法
1595
查看次数

标签 统计

android ×1

google-maps ×1