1

我必须在我的应用程序中加载地图。我已经完成了一切..1.获取密钥和所有..但是现在它显示为普通网格..地图没有加载...请帮助我..

我的活动代码:

public class Mapcctivity extends MapActivity {
    private MapView mMapView = null;  
     private MapController mc = null;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mapcctivity);

        GeoPoint gPoint = new GeoPoint(19240000,-99120000);

        mMapView = (MapView) findViewById(R.id.mView);
        mMapView.setSatellite(true);
        mMapView.setBuiltInZoomControls(true);

        mc = mMapView.getController();
        mc.setZoom(15);
        mc.setCenter(gPoint);
    }

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }


}

我的布局文件:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >



    <com.google.android.maps.MapView
  android:id="@+id/mView"
  android:layout_width="fill_parent" 
  android:layout_height="375dp"
  android:padding="5dp"
  android:enabled="true" 
  android:clickable="true" 
  android:apiKey="My key" />

</LinearLayout>

清单文件:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.map"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="15" />

    <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_LOCATION_EXTRA_COMMANDS" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INERNET" />
    <uses-permission android:name="android.permission.WRITE_GSERVICES" />

    <application



        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=".Mapcctivity"
            android:label="@string/title_activity_mapcctivity" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

</manifest>

当 Map 加载我的 logcat 时是这样的:

12-03 13:48:17.127: D/dalvikvm(3601): GC freed 9551 objects / 643272 bytes in 402ms
12-03 13:52:18.308: E/ActivityThread(3631): Failed to find provider info for com.google.settings
12-03 13:52:18.318: E/ActivityThread(3631): Failed to find provider info for com.google.settings
12-03 13:52:18.357: E/ActivityThread(3631): Failed to find provider info for com.google.settings
12-03 13:52:19.018: D/dalvikvm(3631): GC freed 1919 objects / 127480 bytes in 249ms
12-03 13:52:19.308: I/MapActivity(3631): Handling network change notification:CONNECTED
12-03 13:52:19.317: E/MapActivity(3631): Couldn't get connection factory client
12-03 13:52:19.877: D/dalvikvm(3631): GC freed 4601 objects / 269864 bytes in 121ms
12-03 13:52:24.007: D/dalvikvm(3631): GC freed 13809 objects / 922976 bytes in 137ms
12-03 13:55:31.117: D/dalvikvm(3631): GC freed 9545 objects / 640824 bytes in 163ms
12-03 14:43:38.588: E/ActivityThread(3662): Failed to find provider info for com.google.settings
12-03 14:43:38.598: E/ActivityThread(3662): Failed to find provider info for com.google.settings
12-03 14:43:38.797: E/ActivityThread(3662): Failed to find provider info for com.google.settings
12-03 14:43:40.348: D/dalvikvm(3662): GC freed 1941 objects / 128336 bytes in 219ms
12-03 14:43:41.359: I/MapActivity(3662): Handling network change notification:CONNECTED
12-03 14:43:41.359: E/MapActivity(3662): Couldn't get connection factory client
12-03 14:43:42.547: D/dalvikvm(3662): GC freed 4601 objects / 269880 bytes in 137ms
12-03 14:43:47.217: D/dalvikvm(3662): GC freed 13715 objects / 918384 bytes in 226ms

提前致谢..

4

1 回答 1

0

你把钥匙交给这里了吗?

android:apiKey="My key"

另请注意,您用于签署应用程序的证书仅在您导出时使用。当您在 Eclipse 应用程序中按“运行”时,您的“开发证书”会签名。由于 API 密钥与开发者证书绑定,您必须使用自己的密钥对应用进行签名,或者将 API 密钥更改为为您的开发密钥生成的密钥。

于 2012-12-03T08:42:14.657 回答