Android - Maps Cannot show
Asked Answered
N

2

1

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

Nariko answered 10/12, 2011 at 15:50 Comment(0)
B
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.

Bursar answered 10/12, 2011 at 15:55 Comment(6)
i was sure my API key was correct. i try request new API key and set to my android application.. but it's still give the grid view >_<Nariko
Are you running the app straight from Eclipse, or are you exporting it first and then installing it as an apk on your phone? If you run it from Eclipse, try building it and installing it on your phone. Your error is a typical api-key problem.Kerwon
im straight running my apps on my laptop and my Eclipse IDE. i didnt import/export or running on different device. before i try to write that code, my maps show like normaly, with simple maps. then i try to make overlay button and show the route from lat&lon, then i try to run in my emulator. but what i see is just a grid, no maps like before. @Sander thanks for discuss with need helps @_@Nariko
how about with this error from log cat "Recycling dispatcher android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher@40563470"Nariko
Hmm sorry then I really don't know. I can see nothing wrong in your code, and trying to add an overlay button should not cause a problem like this. I'll keep an eye on this though, and I'll let you know if I think of anything.Kerwon
Just tried running an app of my own which also uses the MapView, and your "error" is not actually an error. It just tells you that the dispatcher object is being recycled. From everything I've experienced myself with MapViews not showing the actual map, it always came down to one of two things. Either the API key was wrong, or I didn't have internet access. Make sure you're getting a new API code from your debug.keystore. The MD5 there has been known to change from time to time.Kerwon
P
1

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

Phanerozoic answered 10/12, 2011 at 16:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.