我想在 Android 中显示谷歌地图,我有地图 API,即使地图没有显示,也没有抛出任何错误。我使用了以下 Java 代码
public class GoogleMapActivity extends MapActivity {
private Location myLocation;
protected MapView myMapView = null;
protected LocationManager myLocationManager = null;
protected MapController mapController;
List<Overlay> mapOverlays;
protected boolean isRouteDisplayed() {
return false;
}
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
this.myMapView = new MapView(this, "0jzIB6m5R1kLa_rGte-DS9PhF3KlSgqYHUZognA");
this.setContentView(myMapView);
myMapView.setBuiltInZoomControls(true);
myMapView.setSatellite(true);
mapController = myMapView.getController();
mapOverlays = myMapView.getOverlays();
this.myLocation = new Location("gps");
this.myLocation.setLongitude(77.52436144125092);
this.myLocation.setLatitude(13.05096452223662);
updateView();
}
private void updateView() {
Double lat = myLocation.getLatitude();
Double lng = myLocation.getLongitude();
GeoPoint point = new GeoPoint(lat.intValue(), lng.intValue());
mapController.setCenter(point);
}
}
显现
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.googlemap"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".GoogleMapActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps" />
</application>
</manifest>
最后我得到输出空白。请看下面的屏幕
请建议我哪里错了