简体   繁体   中英

Android Google Maps connection (doesn't show the map)

When I try to open my app I got an "empty" map, That means I don't see the map, I can see the zoom in and zoom out buttons but there is no map. Please help, here is my code:

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;
    }
}

and here is the logCat logs, as you can see there is a connection problem that I don't know how to fix it:

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)

Are you running on the emulator or the phone? Did you use the correct API key in the layout file? You need one key for when you are running from Eclipse since it uses the debug key to sign the app, you need a second key for when you deploy as an apk that uses your key for signing the app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM