为什么 MapView 显示灰色瓷砖而不是地图? [英] Why does MapView show grey tiles and not the map?

查看:37
本文介绍了为什么 MapView 显示灰色瓷砖而不是地图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我通过创建批处理文件获得了我的 SHA1 指纹.之后,我转到服务"页面并启用了 Google Maps API v2 和 v3.我还转到API 访问"页面并使用 SHA1;PACKAGENAME 创建了一个新的 Android 密钥.之后,我转到我的项目文件夹并添加以下代码:

Ok, so I got my SHA1 fingerprint by creating a batch file. After that, I went to the "Services" page and enabled Google Maps API v2 and v3. I also went to the "API Access" page and created a new Android Key with the SHA1;PACKAGENAME. After this, I went to my project folder and added the following code:

<permission
    android:name            = "com.example.test.permission.MAPS_RECEIVE"
    android:protectionLevel = "signature" 
/>

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

<uses-permission android:name="com.example.test.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-library android:name="com.google.android.maps" />

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

我还创建了一个 XML 文件并粘贴了以下代码:

I also created an XML file and pasted the following code:

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
    xmlns:android           = "http://schemas.android.com/apk/res/android"
    android:id              = "@+id/mapview_MV"
    android:layout_width    = "fill_parent"
    android:layout_height   = "fill_parent"
    android:clickable       = "true"
    android:apiKey          = "APIKEY"
/>

在我的 HTC One X+ 上编译并运行该项目后,我只看到一堆灰色瓷砖.我还尝试在代码中使用 MapView,如下所示:

After compiling and running the project on my HTC One X+, I saw nothing more than bunch of grey tiles. I also tried to use a MapView in code as shown below:

/********************************************************************
* ONCREATE                                                          *
********************************************************************/
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView( R.layout.general_layout );

    MapView mapView = new MapView( GamePage.this, "APIKEY" );
    MapController mc = mapView.getController();
    String coordinates[] = {"1.352566007", "103.78921587"};
    double lat = Double.parseDouble(coordinates[0]);
    double lng = Double.parseDouble(coordinates[1]);

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

    mc.animateTo(p);
    mc.setZoom(17); 

    FrameLayout fl = ( FrameLayout ) findViewById(R.id.general_frameHolder_FL);
    fl.addView(mapView);
}

我看到以下错误:

Couldn't get connection factory client

谁能告诉我我到底做错了什么!?

Can anyone tell me what the hell I'm doing wrong!?

推荐答案

我找到了问题的解决方案.我需要做的是删除 SDK 管理器中的 Google Play 服务并重新安装它,因为由于某种原因我错过了很多包.感谢 Fido,我发现 Google Maps Android v2 API 不支持 MapView 并阅读了整个介绍:https://developers.google.com/maps/documentation/android/start#specifying_permissions.

I found a solution for the problem. What I needed to do was delete the Google Play Services in the SDK Manager and reinstall it, because I missed lots of packages for some reason. Thanks to Fido, I found out that MapView isn't supported in Google Maps Android v2 API and read the whole introduction at: https://developers.google.com/maps/documentation/android/start#specifying_permissions.

在那之后,我还找到了一个可以解决 NoClassFoundError 的网站:http://www.user.tu-berlin.de/hennroja/tutorial_fixing_java.lang.NoClassDefFoundError%20com.google.android.gms.R$styleable.html

After that, I also found a site where you can solve the NoClassFoundError at: http://www.user.tu-berlin.de/hennroja/tutorial_fixing_java.lang.NoClassDefFoundError%20com.google.android.gms.R$styleable.html

我用了 +- 5 个小时才用新的 Google Maps API 解决了这个该死的问题.

It took me +- 5 hours to solve this freaking issue with the new Google Maps API.

这篇关于为什么 MapView 显示灰色瓷砖而不是地图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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