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