Issue
I installed correctly google map api on my app, all works fine with the emulator. But when i transfer it to my phone it doesn't work anymore (there is that grid thing), and i can't find what's wrong.
public class Main extends MapActivity {
/** Called when the activity is first created. */
MapView map ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
map = (MapView)findViewById(R.id.mapview);
map.setSatellite(true);
List<Overlay> mapOverlays = map.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.pins);
HelloItem itemizedoverlay = new HelloItem(drawable, this);
GeoPoint point = new GeoPoint(19240000,-99120000);
OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!");
itemizedoverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedoverlay);
map.setBuiltInZoomControls(true);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
public class HelloItem extends ItemizedOverlay {
private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
private Context mContext;
public HelloItem(Drawable defaultMarker) {
super(boundCenterBottom(defaultMarker));
}
public HelloItem(Drawable defaultMarker, Context context) {
super(boundCenterBottom(defaultMarker));
mContext = context;
}
@Override
protected OverlayItem createItem(int i) {
// TODO Auto-generated method stub
return mOverlays.get(i);
}
public void addOverlay(OverlayItem overlay) {
mOverlays.add(overlay);
populate();
}
@Override
public int size() {
return mOverlays.size();
}
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;
}
}
Solution
This happens because you need to use different .keystore, one is for emulator(debug), one is for device(release). follow the same procedures when you acquired your debug.keystore MD5 & Map API Key from Google. this time you need to acquire both information for your_own.keystore, which is for release on device. then change the Map API Key in your map layout, the map will shown on your device then.
Answered By - miskoL
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.