views:

53

answers:

1

Hello.

Im having problems with the MapView because its not loading the map. I've been reading around, and find many people with the same issue. I checked all the possible issues and it seems that everything is ok :P

  • On the Manifest, the is inside the tag

  • I have the before the tag

  • In the emulator the 3G is working properly since i can navigate with the browser and Google Maps loads perfectly

  • I checked twice my ApiKey, and seems to be ok. Im using Windows, so in the cmd i navigate to the folder where the Java Keytool is located, once there i execute the next command to get the fingerprint and then my ApiKey:

keytool -list -alias androiddebugkey -storepass android -keypass android -key store c:\path\where\the\file\is\located\debug.keystore

Here is some of my code:

public class mapa extends MapActivity {

 private MapView mMapView = null;  
 private MapController mc = null;


 /** Called when the Activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.mapa);

  GeoPoint gPoint = new GeoPoint(40331175,-3765780);

  mMapView = (MapView) findViewById(R.id.mView);
  mMapView.setSatellite(true);
  mMapView.setBuiltInZoomControls(true);

  mc = mMapView.getController();
  mc.setZoom(15);
  mc.setCenter(gPoint);
     }

The XML layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical">

 <com.google.android.maps.MapView
  android:id="@+id/mView"
  android:layout_width="fill_parent" 
  android:layout_height="375dp"
  android:padding="5dp"
  android:enabled="true" 
  android:clickable="true" 
  android:apiKey="My_Api_Key" />

 <RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="3dp"
    android:orientation="vertical">

    <TextView
     android:id="@+id/tMapa"
   android:text="Último dato"
   android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 

    //Here i have some other info, but its not relevant to the problem, since all this views loads properly :P

   </RelativeLayout>      

 </LinearLayout>

AndroidManifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.pfc.android"
      android:versionCode="1"
      android:versionName="1.0">     

    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INERNET" />
    <uses-permission android:name="android.permission.WRITE_GSERVICES" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">

     <uses-library android:name="com.google.android.maps" />

                <!-- I've got here some others Activities declared -->

  <!-- This is the map Activity -->
  <activity android:name=".mapa"
      android:label="@string/app_name"
      class=".mapa">

  </activity>

 </application>

    <uses-sdk android:minSdkVersion="4" />

</manifest> 

So, i dont know what else can i do to solve the issue.

Can anybody help me? :D

A: 

You do not explain what "its not loading the map" means, which makes it difficult to help you.

You do not supply a valid API key in your pasted code, which makes it even more difficult to help you.

Here is a working MapView project -- just paste in your own API key. If that fails, yet the standalone Maps application works fine in the same emulator/device, then your API key is probably invalid.

CommonsWare
The "is not loading" refers that the MapView was showed properly but the only thing i can see was grey squares, meaning that "the map wasnt loading". Anyway, i found the solution to my problem, the ApiKey was correct and everything else was also correct except the Internet uses-permission on the Manifiest. I misstyped INTERNET to INERNET ¬_¬' I dont understand why Eclipse dont warn about that :P
Kitinz