tags:

views:

117

answers:

4

I use the google code from devloper.android.com I use that application but in the emulator it shows only the crossed lines not the map so is there any settings in emulator for displaying maps

              HelloItemizedOverlay.java

              package com.HelloGoogleMaps;

              import java.util.ArrayList;

               import android.app.AlertDialog;
                import android.content.Context;
      import android.graphics.drawable.Drawable;

               import com.google.android.maps.ItemizedOverlay;
              import com.google.android.maps.OverlayItem;

             public class HelloItemizedOverlay extends ItemizedOverlay {
        ArrayList<OverlayItem> mOverlays;
        Context mContext;
        public HelloItemizedOverlay(Drawable defaultMarker) {
     super(boundCenterBottom(defaultMarker));
     mOverlays = new ArrayList<OverlayItem>();
    // TODO Auto-generated constructor stub
}
public HelloItemizedOverlay(Drawable defaultMarker, Context context) {
      super(defaultMarker);
      mContext = context;
    }

@Override
protected OverlayItem createItem(int i) {
    // TODO Auto-generated method stub
     return mOverlays.get(i);

}

@Override
public int size() {
    // TODO Auto-generated method stub
     return mOverlays.size();

}
public void addOverlay(OverlayItem overlay) {
    mOverlays.add(overlay);
    populate();
}
@Override
protected boolean onTap(int index) {
  OverlayItem item = mOverlays.get(index);
  AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
  dialog.setTitle(item.getTitle());
  dialog.setMessage(item.getSnippet());
  dialog.show();
  return true;
}

} HelloGoogleMaps.java

     package com.HelloGoogleMaps;

   import java.util.List;

  import com.google.android.maps.GeoPoint;
   import com.google.android.maps.MapActivity;
   import com.google.android.maps.MapView;
 import com.google.android.maps.Overlay;
 import com.google.android.maps.OverlayItem;

           import android.app.Activity;
          import android.graphics.drawable.Drawable;
          import android.os.Bundle;

     public class HelloGoogleMaps extends MapActivity  {
 /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    MapView mapView = (MapView) findViewById(R.id.mapview);
    mapView.setBuiltInZoomControls(true);
    List<Overlay> mapOverlays = mapView.getOverlays();
    Drawable drawable = this.getResources().getDrawable(R.drawable.androidmarker);
    HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable);

    GeoPoint point = new GeoPoint(19240000,-99120000);
    OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!");

    itemizedoverlay.addOverlay(overlayitem);
    mapOverlays.add(itemizedoverlay);
}

@Override
protected boolean isRouteDisplayed() {
    return false;
}

}

Android mainfest

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".HelloGoogleMaps"
              android:label="@string/app_name"
              android:theme="@android:style/Theme.NoTitleBar">>
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

<uses-library android:name="com.google.android.maps" android:required="true"></uses-library>

A: 

According to this tutorial on "Using Google Maps in Android":

If your application manages to load but you cannot see the map (all you see is a grid), then it is very likely you do not have a valid Map key, or that you did not specify the INTERNET permission [in your manifest]:

<uses-permission android:name="android.permission.INTERNET" />
Brian
I use that permission and also have valid keystore.
bindal
Do you also have the `<uses-library android:name="com.google.android.maps" />` element set as well?
Brian
Yes I also have the user libraray
bindal
had the same problem with grid lines, either internet permission was missing or com.google.android.maps
ArtWorkAD
I have all the settings Right in My program so do u have any idea?
bindal
A: 

Are you inside a proxy network?
If yes, and if you are using your Android 2.1 Emulator, there can be issues like this?

Sen
+1  A: 

Have you put an android:apiKey attribute in your MapView in your xml layout? If not, here is how to obtain an APIKey for you to use the MapView.

M.A. Cape
A: 

Did u develop ur application using Goole API version 8? If so means use google api (version 8) to run ur application.

I too got the same problem earlier. Now i got map on my emulator.

Hope this ll help...

Hendry
Yes i develop on google api version 8 ,how did u find the solution
bindal