谷歌地图不显示在地图上的任何东西在地、图上、东西、地图

2023-09-04 12:33:01 作者:掐死你的温柔

我显示在活动地图......但是当我在设备上运行的应用程序,它不显示任何东西,只显示白色画面,放大缩小选项... MAP关键的是正确的..谢谢..

AndroidManifest.xml中

 < XML版本=1.0编码=UTF-8&GT?;
<舱单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    包=com.edxample.finalmap
    安卓版code =1
    机器人:VERSIONNAME =1.0>

    <用途-SDK
        安卓的minSdkVersion =8
        机器人:targetSdkVersion =17/>



     <允许机器人:名称=com.edxample.finalmap.permission.MAPS_RECEIVE
         安卓的ProtectionLevel =签名/>
     <使用-权限的Andr​​oid:名称=com.edxample.finalmap.permission.MAPS_RECEIVE/>
    <使用-权限的Andr​​oid:名称=android.permission.INTERNET对/>
    <使用-权限的Andr​​oid:名称=android.permission.WRITE_EXTERNAL_STORAG​​E/>
    <使用-权限的Andr​​oid:名称=com.google.android.providers.gsf.permission.READ_GSERVICES/>
    <使用-权限的Andr​​oid:名称=android.permission.ACCESS_COARSE_LOCATION/>
    <使用-权限的Andr​​oid:名称=android.permission.ACCESS_FINE_LOCATION/>

    <使用特征安卓glEsVersion =0x00020000
        机器人:要求=真/>




    <应用
        机器人:allowBackup =真
        机器人:图标=@可绘制/ ic_launcher
        机器人:标签=@字符串/ APP_NAME
        机器人:主题=@风格/ AppTheme>
        <活动
            机器人:名称=com.edxample.finalmap.MainActivity
            机器人:标签=@字符串/ APP_NAME>
            <意向滤光器>
                <作用机器人:名称=android.intent.action.MAIN/>

                <类机器人:名称=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;

        &所述;元数据
            机器人:名称=com.google.android.maps.v2.API_KEY
            机器人:值=AIzaSyBL8ANi3jKkM0tF65C_Qus2_JgWRzClhfU/>

    < /用途>

< /舱单>
 

activity_main.xml

 < RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    的xmlns:工具=htt​​p://schemas.android.com/tool​​s
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    工具:上下文=MainActivity。>

     <片段
        机器人:ID =@ + ID /图
        机器人:layout_width =match_parent
        机器人:layout_height =match_parent
        的xmlns:地图=htt​​p://schemas.andoid.com/apk/es-auto
        机器人:名称=com.google.android.gms.maps.SupportMapFragment/>


< / RelativeLayout的>
 

MainActivity

 包com.edxample.finalmap;

进口com.google.android.gms.common.ConnectionResult;
进口com.google.android.gms.common.GooglePlayServicesUtil;
进口com.google.android.gms.maps.GoogleMap;
进口com.google.android.gms.maps.SupportMapFragment;

进口android.os.Bundle;
进口android.support.v4.app.FragmentActivity;
进口android.view.Menu;
进口android.widget.Toast;

公共类MainActivity扩展FragmentActivity {

    私人GoogleMap的GoogleMap的;
    @覆盖
    保护无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        如果(检查())
        {
            的setContentView(R.layout.activity_main);
            Toast.makeText(这一点,在谷歌播放服务。,Toast.LENGTH_LONG).show();
            initFun();
        }
        其他
        {
            Toast.makeText(这一点,谷歌播放服务不可用,Toast.LENGTH_LONG).show();
        }
    }


    私人布尔检查()
    {
        INT状态= GooglePlayServicesUtil.isGooglePlayServicesAvailable(本);
        如果(状态== ConnectionResult.SUCCESS)
        {
            返回true;
        }

        返回false;
    }

    公共无效initFun()
    {
        SupportMapFragment SP =(SupportMapFragment)getSupportFragmentManager()findFragmentById(R.id.map)。
        GoogleMap的= sp.getMap();
        googleMap.setMyLocationEnabled(真正的);
        googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);


    }


    @覆盖
    公共布尔onCreateOptionsMenu(功能菜单){
        //充气菜单;这增加了项目操作栏,如果它是present。
        。getMenuInflater()膨胀(R.menu.activity_main,菜单);
        返回true;
    }

}
 
分析称谷歌开发iOS应用能提高安卓份额

解决方案

是您的地图API密钥为您debugbuilds或发布版本?关键是根据你的密钥库,这是你的调试和发布版本之间的不同。如果你正在调试你的应用程序,反之为谷歌地图你释放键将无法正常工作。

i am showing a map in activity ... but when i run app on device it does not show any thing , it show just white screen and zoom in zoom out options... MAP key is right .. thanks ..

AndroidManifest.xml

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />



     <permission android:name="com.edxample.finalmap.permission.MAPS_RECEIVE"
         android:protectionLevel="signature" />
     <uses-permission android:name="com.edxample.finalmap.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

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




    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.edxample.finalmap.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>

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

    </application>

</manifest>

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

     <fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        xmlns:map="http://schemas.andoid.com/apk/es-auto"
        android:name="com.google.android.gms.maps.SupportMapFragment" />


</RelativeLayout>

MainActivity

package com.edxample.finalmap;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.widget.Toast;

public class MainActivity extends FragmentActivity  {

    private GoogleMap googleMap;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if(check()) 
        {
            setContentView(R.layout.activity_main);
            Toast.makeText(this, "In Google play service.", Toast.LENGTH_LONG).show();
            initFun();
        }
        else
        {
            Toast.makeText(this, "Google play service not available.", Toast.LENGTH_LONG).show();
        }
    }


    private Boolean check()
    {
        int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
        if(status==ConnectionResult.SUCCESS)
        {
            return true;
        }

        return false;
    }

    public void initFun()
    {
        SupportMapFragment sp = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
        googleMap = sp.getMap();
        googleMap.setMyLocationEnabled(true);
        googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);


    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

}

解决方案

Is your map API key for your debugbuilds or your release builds? The key is based on your keystore, which is different between your debug and release build. Your release key for google maps won't work if you're debugging your app, and vice versa.