谷歌地图瓦片不加载 [英] Google maps tiles doesn't load

查看:176
本文介绍了谷歌地图瓦片不加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发Android一个简单的谷歌地图应用。我使用的Eclipse和Android虚拟设备。当运行应用程序,没有瓷砖显示,和我得到的消息无法获取连接工厂的客户。

我已阅读并看起来是一个错误,但有些人说,他们得到了他们的应用程序的工作。我已经使用API​​ 1.6,2.1,2.2在我的虚拟设备(2.2),其中没有工作尝试。

我从debug.keystore获得从MD5我的API密钥。

我该如何解决这个问题呢?我刚刚发现人同样的问题,但任何解决方案。

清单:

 <?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
      包=uniovi.pfc
      安卓版code =1
      机器人:=的versionName1.0>
    <采用-SDK安卓的minSdkVersion =4/>    <应用机器人:图标=@绘制/图标机器人:标签=@字符串/ APP_NAME>
    <使用库机器人:名字=com.google.android.maps/>
        <活动机器人:名字=。SimpleMap2Activity
                  机器人:标签=@字符串/ APP_NAME>
            &所述;意图滤光器>
                <作用机器人:名字=android.intent.action.MAIN/>
                <类机器人:名字=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;    < /用途>
    <使用许可权的android:NAME =android.permission.ACCESS_FINE_LOCATION>
    < /使用许可权>
    <使用许可权的android:NAME =android.permission.INTERNET对>
    < /使用许可权>
    <使用者许可权的android:NAME =android.permission.ACCESS_COARSE_LOCATION>
    < /用户许可>
< /清单>

XML:

 <?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:方向=垂直
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    >
< com.google.android.maps.MapView
    机器人:ID =@ + ID / mapview1
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    机器人:启用=真
    机器人:可点击=真
    机器人:apiKey =0YSU8-P-YkHYQ2lit-vAsh2U0jW5zV3l_YQVlvw/>< / LinearLayout中>

code:

 包uniovi.pfc;进口com.google.android.maps.GeoPoint;
进口com.google.android.maps.MapActivity;
进口com.google.android.maps.MapController;
进口com.google.android.maps.MapView;进口android.os.Bundle;
进口android.view.KeyEvent;
进口android.view.Window;
进口android.view.WindowManager;公共类SimpleMap2Activity扩展MapActivity {    私人MapView类MapView类= NULL;
    私人MapController mapController = NULL;
    私人的GeoPoint的GeoPoint = NULL;    / **当第一次创建活动调用。 * /
    @覆盖
    公共无效的onCreate(捆绑savedInstanceState){
        super.onCreate(savedInstanceState);
        getWindow()。setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        的setContentView(R.layout.main);        图形页面=(图形页面)findViewById(R.id.mapview1);
        mapController = mapView.getController();        字符串的坐标[] = {40.747778,-73.985556};
        双纬度= Double.parseDouble(坐标[0]);
        双经度= Double.parseDouble(坐标[1]);        的GeoPoint =新的GeoPoint((INT)(LAT * 1E6),(INT)(LNG * 1E6));        mapController.animateTo(GeoPoint对象);
        mapController.setZoom(5);
        mapView.invalidate();
    }    @覆盖
    保护布尔isRouteDisplayed(){
        // TODO自动生成方法存根
        返回false;
    }    公共布尔的onkeydown(INT键code,KeyEvent的事件){
        开关(键code){
        案例KeyEvent.KEY code_I:
            mapController.zoomIn();
            打破;
        案例KeyEvent.KEY code_O:
            mapController.zoomOut();
            打破;        }
        返回super.onKeyDown(键code,事件);
    }}


解决方案

最后,问题是地图apiKey。本主题没有在互联网上很好解释。

不久,我就如下解释:


  1. 要使用映射到一个Android的虚拟机,可以使用debug.keystore

  2. 要使用地图变成一个真正的Andr​​oid设备,你需要创建一个密钥到一个新的密钥库。 Eclipse可以为你做,如果你用鼠标右键单击该项目并导出为签署的apk。

  3. 在这两种情况下,你需要去安慰,并在JAVA JDK /斌/文件夹执行Java工具,称为keytool.exe的。

  4. 如果密钥工具给你SHA1 code,而不是MD5,问题可能是你使用的是Java 7 -v参数添加到密钥工具调用进入详细模式,你也将得到MD5谷歌向您询问。

I'm developing a simple Google Maps app for Android. I'm using Eclipse and an Android Virtual Device. When running the app, no tiles are shown, and I get the message "Couldn't get connection factory client".

I've read and looks like it is a bug, but some people say they got their apps working. I've tried using API 1.6, 2.1, 2.2 over my virtual device (2.2) and none of them work.

I got my API key from the MD5 obtained from the debug.keystore.

How can I solve the problem? I just found people with the same problem, but any solutions.

Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="uniovi.pfc"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="4" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
    <uses-library android:name="com.google.android.maps"/>
        <activity android:name=".SimpleMap2Activity"
                  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>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" >
    </uses-permission>
    <uses-permission android:name="android.permission.INTERNET" >
    </uses-permission>
    <user-permission android:name="android.permission.ACCESS_COARSE_LOCATION">
    </user-permission>
</manifest>

XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<com.google.android.maps.MapView
    android:id="@+id/mapview1"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:enabled="true" 
    android:clickable="true" 
    android:apiKey="0YSU8-p-YkHYQ2lit-vAsh2U0jW5zV3l_YQVlvw" />    

</LinearLayout>

Code:

package uniovi.pfc;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;

public class SimpleMap2Activity extends MapActivity {

    private MapView mapView=null;
    private MapController mapController=null;
    private GeoPoint geoPoint=null;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.main);

        mapView = (MapView) findViewById(R.id.mapview1);
        mapController = mapView.getController();

        String coordinates[] = { "40.747778", "-73.985556" };
        double lat = Double.parseDouble(coordinates[0]);
        double lng = Double.parseDouble(coordinates[1]);

        geoPoint = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));

        mapController.animateTo(geoPoint);
        mapController.setZoom(5);
        mapView.invalidate();
    }

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

    public boolean onKeyDown(int keyCode, KeyEvent event) {
        switch (keyCode) {
        case KeyEvent.KEYCODE_I:
            mapController.zoomIn();
            break;
        case KeyEvent.KEYCODE_O:
            mapController.zoomOut();
            break;

        }
        return super.onKeyDown(keyCode, event);
    }

}

解决方案

Finally, the problem was the maps apiKey. This topic is not very well explained over the internet.

Shortly, I would explain as following:

  1. To use maps into an Android Virtual Machine, you use debug.keystore
  2. To use maps into a real Android device, you need to create a key into a new keystore. Eclipse can do it for you if you right-click the project and export as a signed apk.
  3. In both cases, you need to go to console, and execute a Java tool called keytool.exe at java jdk /bin/ folder.
  4. If keytool gives you the SHA1 code and not the MD5, the problem can be that you are using Java 7. Add -v parameter to the keytool call to enter verbose mode, and you'll get also the MD5 Google asks you for.

这篇关于谷歌地图瓦片不加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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