谷歌地图只显示一个棕色的屏幕和缩放

谷歌地图只显示一个棕色的屏幕和缩放

本文介绍了谷歌地图只显示一个棕色的屏幕和缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to display google maps app in my android application:

我一样在Android开发者提到的步骤:

I did the steps as mentioned in android developer: https://developers.google.com/maps/documentation/android/start

然而,它在我的应用程序显示对我来说,变焦棕色屏幕(加号和减号按钮)未经地图本身(它不给我任何错误)

However it display for me in my app , a brown screen with zoom (plus and minus buttons) without the map itself (it doesnt show me any error)

我创造了这个XML文件:

I created this xml file:

<?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>

这是我的清单文件:

And this is my manifest file:

<?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

>

推荐答案

更改此:

<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" />

我不知道这是否会帮助,但这个布局code我用最后一个项目
(注意:不同的片段级)

I'm not sure if this will help but this is layout code I used last project(note different fragment class)

<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>

这篇关于谷歌地图只显示一个棕色的屏幕和缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 15:02