嗨,我是 android 编程的新手,我遵循了许多教程中的步骤,但我只设法显示了谷歌地图,它只在模拟器和设备上显示瓷砖。提前谢谢了!
这是我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="bi.com.biosensors"
android:versionCode="1"
android:versionName="1.0" >
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-permission android:name="bi.com.biosensors.mapdemo.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name=".SplashScreen"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".BiMain"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait"
android:label="@string/app_name" >
</activity>
<activity android:name=".Products" >
</activity>
<activity android:name=".ContactUs" >
</activity>
<activity android:name=".WebMapViewActivity" >
</activity>
<activity android:name=".WebViewActivity" >
</activity>
<activity android:name=".openAccuActivity" >
</activity>
<activity android:name=".BusesNearby" >
</activity>
<activity android:name=".openBiotransActivity" >
</activity>
<activity android:name=".openMultiLuActivity" >
</activity>
<activity android:name=".openThermoActivity" >
</activity>
<activity android:name=".openBiotrayActivity" >
</activity>
<activity android:name=".openBipolarActivity" >
</activity>
<activity android:name=".openEmboActivity" >
</activity>
<activity android:name=".openBioflexActivity" >
</activity>
<activity android:name=".openAxxessActivity" >
</activity>
<activity android:name=".openGazelleActivity" >
</activity>
<activity android:name=".openPowerlActivity" >
</activity>
<activity android:name=".AlertCaution" >
</activity>
<activity android:name=".BusRoutes" >
</activity>
<activity android:name=".AllBuses" >
</activity>
<activity android:name=".bus5route" >
</activity>
<activity android:name=".bus15route" >
</activity>
<activity android:name=".bus58route" >
</activity>
<activity android:name=".bus59route" >
</activity>
<activity android:name=".bus87route" >
</activity>
<activity android:name=".mrtMap" android:screenOrientation="portrait" >
</activity>
<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCFLLz6m3N1WEKNG6KnwvoQvMBTC4r9AzA"/>
</application>
</manifest>
还有我的 xml(我很确定我有正确的 API 密钥):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="***************"
/>
</RelativeLayout>
和我的java代码:
public class WebMapViewActivity extends MapActivity {
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapview);
getActionBar();
ActionBar actionBar = getActionBar();
actionBar.setIcon(R.drawable.ic_menu_mapmode);
actionBar.setTitle("Map");
MapView mapView = (MapView) findViewById(R.id.mapView);
mapView.setBuiltInZoomControls(true);
List<Overlay> mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.ic_launcher);
HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable,this);
GeoPoint point = new GeoPoint(133339,-10390584);
OverlayItem overlayitem = new OverlayItem(point, "Hello!","This is Biosensors Interventional Singapore !");
itemizedoverlay.addOverlay(overlayitem);
MapController mapController = mapView.getController();
mapController.setCenter(point);
mapOverlays.add(itemizedoverlay);
}
@Override
protected boolean isRouteDisplayed()
{
return false;
}
}