Android - Maps Cannot show

百般思念 提交于 2019-12-06 13:45:25

问题


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


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/8457729/android-maps-cannot-show

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!