Reputation: 211
I'm using google map in my app , the code runs on device perfectly but the map does not load ! I just see a white screen ! what's the problem ?
here is the code , please help !
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;
}
}
Upvotes: 0
Views: 207
Reputation: 41
Create your google map api key and pest in maplayout.xml
android:apiKey=" your api key"
which is freely avaliable
Upvotes: 0