0

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;
   }
}
1
  • can you add your manifest file and xml file hear Commented Apr 30, 2012 at 7:28

2 Answers 2

2

put your map api key in xml here is tutorial to get map api key

Sign up to request clarification or add additional context in comments.

Comments

0

Create your google map api key and pest in maplayout.xml

android:apiKey=" your api key"

which is freely avaliable

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.