0

我想在我的 android 应用程序中显示谷歌地图应用程序:

我做了android开发人员中提到的步骤:https ://developers.google.com/maps/documentation/android/start

但是它在我的应用程序中为我显示,一个带有缩放(加号和减号按钮)的棕色屏幕,没有地图本身(它没有向我显示任何错误)

我创建了这个 xml 文件:

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >



    <ImageView
        android:id="@+id/itemImage"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:src="@drawable/logo" />

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="400dp"
        android:layout_marginTop="10dp"
        android:layout_weight="66496.79"
        android:orientation="horizontal" >


        <fragment 
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:name="com.google.android.gms.maps.MapFragment"/>


    </RelativeLayout>

</LinearLayout>

这是我的清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.sal"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true"/>



    <uses-sdk
        android:minSdkVersion="1"
        android:targetSdkVersion="17" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.CAMERA"/>

    <permission
    android:name="com.example.sal.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <!-- The following two permissions are not required to use
     Google Maps Android API v2, but are recommended. -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
        <uses-permission android:name="com.example.sal.permission.MAPS_RECEIVE"/>
        <uses-permission android:name="android.permission.READ_PHONE_STATE"/>




    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" 
        android:name=".FriendPickerApplication">



        <activity
            android:name="com.example.sal.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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


              </activity>

         <!--  Entry for RegisterActivity.class -->
        <activity android:name=".RegisterActivity"
                  android:label="Register New Account"></activity>
        <meta-data android:value="@string/app_id" android:name="com.facebook.sdk.ApplicationId"/>
        <activity android:label="@string/app_name" android:name="com.facebook.LoginActivity"></activity>
        <activity android:name=".ProfileActivity" android:label="Profile page"></activity>

        <meta-data
              android:name="com.google.android.maps.v2.API_KEY"
              android:value="zzzz"/>


        <activity android:name="SaleMapActivity"></activity>
        <activity android:name="GroupMapActivity"></activity>
        <activity android:name="DeliverMapActivity"></activity>
        <activity android:name="PickFriendsActivity"></activity>
        <activity android:name="TabMainActivity"></activity>
        <activity android:name="itemSaleActivity"></activity>
        <activity android:name="FreindsActivity"></activity>
        <activity android:name="ExitActivity"></activity>
        <activity android:name="OneTimeDetailesScreen"></activity>
        <activity android:name="UpdateMapActivity"></activity>
        <activity android:name="DashBoardActivity"></activity>

    </application>

</manifest

>

4

1 回答 1

0

改变这个:

<permission
    android:name="com.vogella.android.locationapi.maps.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<permission
    android:name="com.example.sal.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

我不确定这是否有帮助,但这是我上一个项目使用的布局代码(注意不同的片段类)

<fragment
    android:id="@+id/map_fragment"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    class="com.google.android.gms.maps.SupportMapFragment"
    map:mapType="normal"
            map:cameraTargetLat="@string/default_map_lat"
            map:cameraTargetLng="@string/default_map_lng"
            map:cameraZoom="8">
</fragment>
于 2013-03-27T11:01:01.643 回答