谷歌地图Android上的空白页(白色) [英] Google Map on Android BLANK PAGE (white)

查看:177
本文介绍了谷歌地图Android上的空白页(白色)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图dispaly在我的应用程序的基本谷歌地图,这不是工作它显示一个白色的屏幕,而不是即使我有一个网络连接还检查我的MANEFIST一百倍,我genrated一个deubg键并深信这是真正

我想如果有人可能会导致我什么我做错了?

我也没有修改code,但对于第二个模拟器上的地图diplayed和消失,我的设备上它根本不突然就根本不会在模拟器上显示。






公共类MyMapDisplayActivity扩展MapActivity {

  MapController MControl;
GeoPoint的GeoP;
MapView类MapView类;/ **当第一次创建活动调用。 * /
@覆盖
公共无效的onCreate(捆绑savedInstanceState){
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.main);            //地图
            MapView类MapView类=(图形页面)findViewById(R.id.mapview);
             mapview.displayZoomControls(真);
             mapview.setBuiltInZoomControls(真);             双纬度= 19.7888;
             双隆基= 52.535;
             GeoP =新的GeoPoint((INT)(LAT * 1E6),(INT)(隆基* 1E6));
             MControl = mapview.getController();
             MControl.animateTo(GeoP);
             MControl.setZoom(14);
             MyLocationOverlay LocationOverlay =新MyLocationOverlay(这一点,MapView类);
             调用MapView.getOverlays()加(LocationOverlay)。
             LocationOverlay.enableCompass();
             LocationOverlay.enableMyLocation();
} //的onCreate//地图
@覆盖
保护布尔isRouteDisplayed(){
返回false;
}






 <的LinearLayout
         机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:ID =@ + ID / TAB2
        机器人:方向=垂直
        机器人:paddingTop =60像素
         >
        < com.google.android.maps.MapView
        机器人:ID =@ + ID /图形页面
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT
        机器人:启用=真
        机器人:可点击=真
        机器人:apiKey =0jiwJEbT6if6dhaf0x6Fr_zRLsrz_CYxcLGj6pQ
                 />< / LinearLayout中>





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


解决方案

您必须创建两个不同的API密钥,一个与模拟器调试签名密钥和一个与你用于登录设备的APK的关键。

Am trying to dispaly a basic google map on my application but that's not working it display a white screen instead even though I have a net connection also I check my MANEFIST a hundred times and I genrated a deubg key and am sure it is true

I would like if anyone could lead me what am doing wrong ?

I also haven't modified the code but for a second on the EMULATOR the map diplayed and disappeared and on my device it doesn't AT ALL suddenly it doesn't display AT ALL on the emulator.



public class MyMapDisplayActivity extends MapActivity {

MapController MControl;
GeoPoint GeoP;
MapView mapview;



/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

            //Map
            MapView mapview = (MapView) findViewById(R.id.mapview);
             mapview.displayZoomControls(true);
             mapview.setBuiltInZoomControls(true);

             double lat = 19.7888;
             double longi = 52.535;


             GeoP = new GeoPoint ((int) (lat *1E6),(int) (longi *1E6));


             MControl = mapview.getController();
             MControl.animateTo(GeoP);
             MControl.setZoom(14);




             MyLocationOverlay LocationOverlay = new MyLocationOverlay(this, mapview);
             mapview.getOverlays().add(LocationOverlay);
             LocationOverlay.enableCompass();
             LocationOverlay.enableMyLocation();
}//onCreate

//Map
@Override
protected boolean isRouteDisplayed() {
return false;
}





    <LinearLayout
         android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/tab2"
        android:orientation="vertical"
        android:paddingTop="60px"
         >
        <com.google.android.maps.MapView
        android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:enabled="true"
        android:clickable="true"
        android:apiKey="0jiwJEbT6if6dhaf0x6Fr_zRLsrz_CYxcLGj6pQ"
                 />

</LinearLayout>





<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="jdisplay.map"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />
             <uses-permission android:name="android.permission.INTERNET"></uses-permission>
             <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
             <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".BatteryprojectActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <uses-library android:name="com.google.android.maps" />
        </application>

</manifest>

解决方案

You have to create two different API keys, one with the debug signing key for the emulator and one with the key you use to sign the apk for the device.

这篇关于谷歌地图Android上的空白页(白色)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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