0
我在我的應用中使用谷歌地圖,代碼在設備上運行完美,但地圖不加載!我只是看到一個白色的屏幕!有什麼問題 ?android:谷歌地圖加載問題
這裏是代碼,請幫忙!
public class MyMap extends MapActivity {
private MapView map;
private MapController controller;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initMapView();
initMyLocation();
}
/** Find and initialize the map view. */
private void initMapView() {
map = (MapView) findViewById(R.id.map);
controller = map.getController();
map.setSatellite(true);
map.setBuiltInZoomControls(true);
}
/** Start tracking the position on the map. */
private void initMyLocation() {
final MyLocationOverlay overlay = new MyLocationOverlay(this, map);
overlay.enableMyLocation();
//overlay.enableCompass(); // does not work in emulator
overlay.runOnFirstFix(new Runnable() {
public void run() {
// Zoom in to current location
controller.setZoom(8);
controller.animateTo(overlay.getMyLocation());
}
});
map.getOverlays().add(overlay);
}
@Override
protected boolean isRouteDisplayed() {
// Required by MapActivity
return false;
}
}
你有API密鑰嗎? – jcxavier 2012-04-26 15:11:07
是你的問題解決? – 2012-04-29 03:21:06
你可以添加你的清單文件和XML文件聽到 – 2012-04-30 07:28:00