Android - Maps Cannot show

2020-07-30 03:49发布

i wanna show google maps on my android application. show i do some basic step like this :

AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />

maps.xml

<view android:id="@+id/mv"
        class="com.google.android.maps.MapView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1" 
        android:clickable="true"
        android:apiKey="0cNoErXkpZDlKvCYr_OFj5xZD39-***********"
    />

and this is may maps class, import and onCreate method

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;

method onCreate() on maps class

    public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.maps);

    mapView = (MapView)findViewById(R.id.mv);
    mapView.setSatellite(false);
    mapView.setTraffic(false);
    mapView.setBuiltInZoomControls(true);

    int maxZoom = mapView.getMaxZoomLevel();
    int initZoom = maxZoom-2;

    mapControl = mapView.getController();
    mapControl.setZoom(initZoom);

    latE6 = (int) (lat*1e6);
    lonE6 = (int) (lon*1e6);
    gp = new GeoPoint(latE6, lonE6);
    mapControl.animateTo(gp);

    overlayButton = (Button)findViewById(R.id.doOverlay);

but why my map didnt show, i only see the grid whithout maps, and when i try to read logcat, i see this error with yellow color

Recycling dispatcher android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher@40563470

please help me. thanks mate

2条回答
你好瞎i
2楼-- · 2020-07-30 03:59

Are you sure your API key is correct? When the API key doesn't match, it shows the grid instead of the map.

Running the app from Eclipse directly on the emulator / an actual phone requires a different key then when you build the .apk file first and run that on a device.

查看更多
Luminary・发光体
3楼-- · 2020-07-30 04:21

-If you have internet over proxy you will get grids . -Use the default debug keystore for generating API key and try .

查看更多
登录 后发表回答