谷歌地图API V3显示灰色框只 [英] Google Maps API v3 shows GRAY BOXES only

查看:197
本文介绍了谷歌地图API V3显示灰色框只的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新的开发者,但我花了几天来试图解决显示在Android device.I的地图了,而不是灰色框这个问题已经阅读关于一切有阅读有关这些箱子但正在努力解决方案其他人都没有为我工作。

New developer but I have spent the past few days trying to resolve this problem of gray boxes showing up instead of a map on Android device.I have read just about everything there is to read about these boxes but the solutions that are working for other people are not working for me.

我使用的API密钥使用命令从bin文件夹来自密钥工具在我的Java JRE 7文件夹:
密钥工具-list -alias androiddebugkey -keystoreC:\\用户\\ ben.android \\ debug.keystore-storepass的android -keypass android的-v
....我相信这是我读过关于<一个调试API密钥href=\"http://stackoverflow.com/questions/16955701/google-maps-shows-grey-tiles-only-not-map\">here以及其他地方。

下面是我得到的 http://imgur.com/IoHMHQc 中的错误。我相信我还突出了有趣的一部分,这就是 java.io.IOException异常:服务器返回:3

Here is the error I am getting http://imgur.com/IoHMHQc. I believe I have highlighted the "interesting" part which is java.io.IOException: Server returned: 3.

好像这意味着我的API密钥有缺陷,但我做了多个新的和没有似乎来解决这个问题!
我不是在上传应用程序又是那么我不认为无/有符号出口问题,但是那是因为我不完全理解它。

It seems like that means my API key is faulty but I have made multiple new ones and none seem to fix the problem! I am NOT uploading the application yet so I don't think the "signed/unsigned" exporting matters but that is because I don't understand it completely.

我曾尝试以下多个教程如来自Lynda.com以及各种YouTube的教程,但他们都是谷歌地图2版,而不是V3,这样可能是问题。帮助将不胜AP preciated救生!

I have tried following multiple tutorials such as one from Lynda.com as well as various youtube tutorials, however they all are Google Maps v2 rather than v3 so that may be the issue. Help would be greatly appreciated and lifesaving!

下面是我的主要的Java文件:

Here is my main java file:

package com.bentseytlin.gmap2;

import com.google.android.maps.MapActivity;

import com.google.android.maps.MapView;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends MapActivity {

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

        MapView view = (MapView) findViewById(R.id.themap);
                view.setBuiltInZoomControls(true);

    }

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

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

}

下面是我的XML文件:

Here is my xml file:

<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"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

  <com.google.android.maps.MapView

       android:layout_width="fill_parent"
       android:layout_height="fill_parent"    
       android:id="@+id/themap"
       android:clickable="true"
       android:apiKey="AIzaSyB1gqlqGQZCH1TlrDhp5BP9Pm9k4Jm_2co"
       />

</RelativeLayout>

这是我的清单文件:

And here is my Manifest File:

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

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="17" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

    <application
        android:allowBackup="true"
        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="com.bentseytlin.gmap2.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>
    </application>

</manifest>

再次感谢!

推荐答案

请确保您已按照以下链接中的所有步骤

Make sure you have followed all the steps in the below link

https://developers.google.com/maps/documentation/android/start 。 (API V2)

https://developers.google.com/maps/documentation/android/start. (api v2)

您应该参考Google服务库项目在地图中的项目

You should refer to google services library project in your map project

下载谷歌播放services.Goto的Windows。转到Android SDK中管理器。选择谷歌玩下额外服务。如果没有安装安装软件包。

Download the Google Play services.Goto Windows. Goto Android Sdk Manager. Choose Google play services under extras. If not installed install the package.

在谷歌播放services_lib库项目复制到您的工作空间。库项目可以在以下路径下找到。

Copy the google-play services_lib library project to your workspace. The library project can be found under the following path.

 <android-sdk-folder>/extras/google/google_play_services/libproject/google-play-services_lib library project .

导入库项目到Eclipse。

Import the library project to your eclipse.

点击文件>导入,选择的Andr​​oid>现有Android的code到工作区,浏览该工作区导入库项目。你可以检查它是否是库项目。右键单击库项目。转到属性。点击左侧面板上的Andr​​oid。你将看到的是库检查。

Click File > Import, select Android > Existing Android Code into Workspace, and browse the workspace import the library project. You can check if it is library project. Right click on the library project. Goto properties. Click Android on the left panel. You will see Is Library checked.

要参考库项目

右键点击你的Andr​​oid地图项目。转到属性。选择Android系统。单击添加borwse并添加库项目。

Right click on you android map project. goto properties. Choose Android. Click Add borwse and add the library project.

假设你有钥匙。

请确保您已启用谷歌地图服务中的选项卡下的谷歌API控制台的机器人。

Make sure you have enabled google maps for android in the google api console under the services tab.

您分钟SDK是10.您应该使用支持片段。

Your min sdk is 10. You should use Support Fragment.

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

您活动必须延长 FragmentActivity

SupportMapFragment fm = (SupportMapFragment)  getSupportFragmentManager().findFragmentById(R.id.map);
GoogleMap mMap = fm.getMap(); 

请确保您已经添加支持库

Make sure you have added support library

另外,还要确保您导入下面的

Also make sure you imported the below

import android.support.v4.app.FragmentActivity;  
import com.google.android.gms.maps.SupportMapFragment;    

在manifest文件中添加这些

Add these in manifest file

  <permission
    android:name="com.bentseytlin.gmap2.permission.MAPS_RECEIVE"
    android:protectionLevel="signature"/>
 <uses-permission android:name="com.bentseytlin.gmap2.permission.MAPS_RECEIVE"/>  
 <uses-feature
    android:glEsVersion="0x00020000"
    android:required="true"/>  

在清单中添加项下的应用程序标签

Add the key in manifest under application tag

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

这篇关于谷歌地图API V3显示灰色框只的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆