我的 getMap() 方法返回 null。为什么这个方法返回null?我查看了 Android Developers 文档以确保我正确使用了此方法。这是我用来获取地图的代码行:
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.myMapView)).getMap();
这是我的Java代码:
private ProjectionProxy proxy = new ProjectionProxy();
private GoogleMap mMap;
@Override
protected void onCreate(Bundle load) {
super.onCreate(load);
setContentView(R.layout.fragment_ride_tracking);
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.myMapView)).getMap();
Log.e("RideTracking", "Google Map VALUE:"+mMap);
if (mMap != null) {
proxy.setProjection(mMap.getProjection());
}
这是该特定代码的 XML 代码:
<fragment
android:id="@+id/myMapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
这是 logcat 输出:
05-09 12:49:34.282: W/GooglePlayServicesUtil(5928): Google Play services out of date. Requires 3027100 but found 2012110
05-09 12:49:34.282: E/RideTracking(5928): Google Map VALUE:null
05-09 12:49:34.302: E/OGT.GPSLoggerServiceManager(5928): No GPSLoggerRemote service connected to this manager
05-09 12:49:34.322: W/dalvikvm(5928): Unable to resolve superclass of Lcom/android/gpstracker/viewer/FixedMyLocationOverlay; (2174)
05-09 12:49:34.322: W/dalvikvm(5928): Link of class 'Lcom/android/gpstracker/viewer/FixedMyLocationOverlay;' failed
05-09 12:49:34.322: W/dalvikvm(5928): Unable to resolve superclass of Lcom/android/gpstracker/viewer/FixedMyLocationOverlay; (2174)
任何帮助将不胜感激!