android谷歌地图无法加载

时间:2015-05-22 14:19:54

标签: android eclipse google-maps

我的问题是当应用程序连接到Google Map APi V2时地图未加载 它连接没有任何错误,但地图没有加载 Zoom Buttom出现但是......

请帮帮我

如果您有任何Simale代码我可以使用它请给我 感谢

它的manifest.xml

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

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="16" />

    <permission 
    android:name="com.example.maps.permission.MAP_RECEIVE"
    android:protectionLevel="signature"/>

<uses-permission android:name="com.example.maps.permission.MAP_RECEIVE"/>
<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="com.googel.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="0x0002000"
    android:required="true"/>



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


    <activity
        android:name=".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.geo.API_KEY"
        android:value="[edited]"/>

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />


</application>

它是Xml文件

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>

它的主要活动

package com.example.maps;

import android.support.v4.app.FragmentActivity;
import android.os.Bundle;

public class MainActivity extends FragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.maps);
    }

}

2 个答案:

答案 0 :(得分:0)

您确定元数据名称是&#34; com.google.android.geo.API_KEY &#34;而不是&#34; com.google.android.maps.v2.API_KEY &#34;。请你检查一下。

答案 1 :(得分:0)

确保在manifest.xml中使用它

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

<meta-data android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />

您使用 com.google.android.geo.API_KEY ,而不是 com.google.android.maps.v2.API_KEY

更新

您的MainActivity似乎没有加载地图。一个简单的例子如下:

private GoogleMap mMap;

if (mMap == null) {
        // Try to obtain the map from the SupportMapFragment.
        mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
                .getMap();
        // Check if we were successful in obtaining the map.
        if (mMap != null) {
            Location locationdefault = new Location("NewYork");
            locationdefault.setLatitude(41.145495);
            locationdefault.setLongitude(−73.994901);

}