tags:

views:

38

answers:

2

Hi , I have developing apps with google map .I follow material from android developers site and some other guidelines .wen i run the program the icon only point to the location .in background no map view displayed.can any one help to me ?

Thanks in advance Regards Lakshmanan.

Here is my source code,

public class MapPage extends MapActivity
{

MapView mapView; 
MapController mc;
GeoPoint p;

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView) findViewById(R.id.mapview); mapView.setBuiltInZoomControls(true);

List<Overlay> mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.icon);
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);
mc = mapView.getController();
String coordinates[] = {"1.352566007", "103.78921587"};
double lat = Double.parseDouble(coordinates[0]);
double lng = Double.parseDouble(coordinates[1]);

p = new GeoPoint(
    (int) (lat * 1E6), 
    (int) (lng * 1E6));

mc.animateTo(p);
mc.setZoom(1); 
mapView.invalidate();

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

}

java class :

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

@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; } @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(); }

}

file:///home/aspirel3/Desktop/Screenshot.png

screen shot: /home/aspirel3/Desktop/Screenshot.png

+2  A: 

My suspicion is that you are not specifying the correct google maps key. You need to specify the google maps key that is generated for the keystore you are signing your application with.

I don't see the key being set in the code (You need to set it in the constructor of the MapView or using the attribute android:apiKey if you are constructing a MapView from an xml layout). If you don't do this you usually end up with a gray screen, the overlays and then a Google watermark in the lower left hand corner, which I am guessing you are getting. Here is the link for the place to get a map key. Sign Up for the Android Maps Api

Greg
hin thanks for ur reply.I included the api key in my xml file,still i get the same output.
Lakshmanan
thanks for ur comments,Ihad included the api key in xml file but am getting same outputonly.
Lakshmanan
am new to this site,i dont know how to include the links.let me know how to include as a link..
Lakshmanan
Your inclusion of the links is fine, however file:///home/aspirel3/Desktop/Screenshot.png and screen shot: /home/aspirel3/Desktop/Screenshot.pngare only local to your machine. No one else can see or access them. You need to upload to some other space that is world readable.
Greg
Also for your API Key, you should verify that the keystore and API key match. There is going to be a different API key for the debug keystore and the release keystore (the keystore you use if you are going to be using the Android market)
Greg
+1  A: 

Hi, I also think that you need to include the Maps API key. I prefer the inclusion within a seperate map.xml:

<?xml version="1.0" encoding="utf-8"?>

<!-- The Api Key needs to be replaced corresponding to the signing certificate. 
    Check this site for more info:
    http://code.google.com/intl/ko/android/maps-api-signup.html  -->
<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/myMap"
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    android:enabled="true" android:clickable="true"
    android:apiKey="@+string/maps_api_key" />

Then I include this file in any of my map views like this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/myMapView" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <include layout="@layout/map" />
</RelativeLayout>
Keyboardsurfer
thanks, am included the api key in my xml file but still i get same output.
Lakshmanan
be sure to use the correct tool for extracting your keys fingerprint as described over at http://code.google.com/intl/ko/android/maps-api-signup.html
Keyboardsurfer