0
我在我的應用程序中正確安裝了google map api,所有工作都可以正常使用模擬器。但是,當我將它傳輸到我的手機時,它不再工作(有那個網格的東西),我找不到錯在哪裏。MapView適用於模擬器,但不適用於手機
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;
}
}
這是一個重複的問題。看到類似的問題:http://stackoverflow.com/questions/1809507/android-hello-mapview-tutorial-map-tiles-do-not-load – Brian 2011-03-31 14:33:50
我做了所有這一切,它與日食,但不是在我的手機上正常工作。 – Tsunaze 2011-03-31 14:37:17
缺少互聯網連接? – 2red13 2011-03-31 14:39:18