2

当我尝试打开我的应用程序时,我得到一个“空”地图,这意味着我看不到地图,我可以看到放大和缩小按钮,但没有地图。请帮忙,这是我的代码:

package com.example.hichride;

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.app.Activity;
import android.view.Menu;

public class MainActivity extends MapActivity {


    MapController mControl;
    GeoPoint GeoP;
    MapView mapV;


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

        mapV = (MapView) findViewById(R.id.mapView);
        mapV.displayZoomControls(true);
        mapV.setBuiltInZoomControls(true);

        double lat = 40.8;
        double longi = -96.666;

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

        mControl= mapV.getController();
        mControl.animateTo(GeoP);
        mControl.setZoom(13);


    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

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

这是logCat日志,您可以看到有一个我不知道如何解决的连接问题:

07-31 19:55:37.878: W/MapActivity(746): Recycling dispatcher android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher@411fa278
07-31 19:55:37.918: V/MapActivity(746): Recycling map object.
07-31 19:55:38.178: I/MapActivity(746): Handling network change notification:CONNECTED
07-31 19:55:38.188: E/MapActivity(746): Couldn't get connection factory client
07-31 19:56:26.201: W/System.err(746): IOException processing: 26
07-31 19:56:26.201: W/System.err(746): java.io.IOException: Server returned: 3
07-31 19:56:26.208: W/System.err(746):  at android_maps_conflict_avoidance.com.google.googlenav.map.BaseTileRequest.readResponseData(BaseTileRequest.java:115)
07-31 19:56:26.208: W/System.err(746):  at android_maps_conflict_avoidance.com.google.googlenav.map.MapService$MapTileRequest.readResponseData(MapService.java:1473)
07-31 19:56:26.208: W/System.err(746):  at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.processDataRequest(DataRequestDispatcher.java:1117)
07-31 19:56:26.208: W/System.err(746):  at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.serviceRequests(DataRequestDispatcher.java:994)
07-31 19:56:26.208: W/System.err(746):  at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher$DispatcherServer.run(DataRequestDispatcher.java:1702)
07-31 19:56:26.208: W/System.err(746):  at java.lang.Thread.run(Thread.java:856)
4

1 回答 1

4

你是在模拟器还是手机上运行?您是否在布局文件中使用了正确的 API 密钥?当您从 Eclipse 运行时需要一个密钥,因为它使用调试密钥对应用程序进行签名,当您部署为使用您的密钥对应用程序进行签名的 apk 时,您需要第二个密钥。

于 2012-07-31T20:06:26.810 回答