can not display map

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

can not display map

Postby reza » Tue Jan 25, 2011 11:49 pm

Hi.
I have 2 activity. In one activity, I have a button. In the click event of that button, I want to open a map, in a new activity.
But I have no clue why I am having error when I click the button. it says "application has stopped unexpectedly, please try again."
This is my button click event---
Code: Select all
Button btnDrive=(Button)findViewById(R.id.btnDrive);
        btnDrive.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent myIntent=new Intent(v.getContext(),WebiMapActivity.class);
            startActivityForResult(myIntent,0);
            
         }
      });


This is my map activity---

Code: Select all
public class WebiMapActivity extends MapActivity{
   private MapView mapView;
   private MapController mapController;
   
   @Override
   protected boolean isRouteDisplayed() {
      // TODO Auto-generated method stub
      return false;
   }
   @Override
   public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.mapview);
   mapView = (MapView)findViewById(R.id.map_view);
   mapView.setStreetView(true);
   mapView.displayZoomControls(true);
   mapController=mapView.getController();
   
   }
   
   

}


Any there any help for this??
N.B: i have permission for internet in the manifest.xml.
reza
Freshman
Freshman
 
Posts: 9
Joined: Sat Jan 22, 2011 12:29 am

Top

Re: can not display map

Postby reza » Wed Jan 26, 2011 12:34 pm

Hi.
the error turned into a new kind of problem. Now I can see the some gray tiles and written google at the bottom-left corner but I do not see any map.
I also tried the HelloMapView tutorial from http://www.android.com but still I can not see the map. I even see the marker but not the map.
I can guess that it is not for my program. It must be something with some kind of settings.
Here is my manifest.xml
Code: Select all
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.map"
      android:versionCode="1"
      android:versionName="1.0">
      <uses-permission android:name="android.permission.INTERNET"/>
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <uses-library android:name="com.google.android.maps"/>
        <activity android:name=".helloMap"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
    <uses-sdk android:minSdkVersion="9" />

</manifest>


here is my layout main.xml
Code: Select all
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="0lKgVRkBn3SfF_YSq-EPN9LHcHQ9HBr4ZtGgIlg"
/>
</LinearLayout>

Any idea how to solve it?
reza
Freshman
Freshman
 
Posts: 9
Joined: Sat Jan 22, 2011 12:29 am

Re: can not display map

Postby JoxTraex » Wed Jan 26, 2011 9:52 pm

Make sure that your emulator does have an internet connection (if you are using an emulator). If you can, try it on a physical device. Typically The blank map shows up when no data has been downloaded through the dedicated internet connection, be it 3G or Wifi. This should fix the problem. Another thing to try if this fails, is to get another maps key and copy and paste it into the project.

In order to determine if the emulator is connected ensure that it says 3G at the top of the emulator, if it shows the bars with an x on top of it, this mean there is no internet connection.

Jox :D
JoxTraex
Developer
Developer
 
Posts: 25
Joined: Wed Jan 26, 2011 12:29 am

Re: can not display map

Postby reza » Fri Jan 28, 2011 8:57 am

Hi Thanx
This problem has been solved. The problem was with my mapkey.
I made a new mapkey and it is working fine now.
reza
Freshman
Freshman
 
Posts: 9
Joined: Sat Jan 22, 2011 12:29 am

Re: can not display map

Postby ish_nathan » Thu Feb 10, 2011 12:58 am

I still am not able to see the map. :(
ish_nathan
Freshman
Freshman
 
Posts: 2
Joined: Thu Feb 10, 2011 12:13 am

Re: can not display map

Postby manish raj » Sat Feb 12, 2011 9:23 am

Hi, i have also same problem with map.I am getting map in googleMap app but in my app.so i can say problem must not in INTERNET in emulator.Any body have any idea please help me.
device.png
this is i am getting
device.png (9.27 KiB) Viewed 505 times


XML layout code

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout
  3.  xmlns:android="http://schemas.android.com/apk/res/android"
  4.  android:id="@+id/frame"
  5.  android:orientation="vertical"
  6.  android:layout_width="fill_parent"
  7.  android:layout_height="fill_parent">
  8.   <com.google.android.maps.MapView
  9.                 android:id="@+id/maps"
  10.                 android:apiKey="0HLQkH9ji3tQNz6fw39n5eNzN5OxDZ6aFSUFFZQ"
  11.                 android:layout_width="fill_parent"
  12.                 android:layout_height="fill_parent"
  13.                 android:enabled="true"
  14.                 android:clickable="true" />
  15. </LinearLayout>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4

location java code
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package geomanager.android.map;
  2.  
  3. import android.os.Bundle;
  4. import com.google.android.maps.MapActivity;
  5. import com.google.android.maps.MapController;
  6. import com.google.android.maps.MapView;
  7. import com.google.android.maps.MyLocationOverlay;
  8.  
  9. public class location extends MapActivity  {
  10.         private MapView mapp;
  11.         private MapController controller;
  12.        
  13.         @Override
  14.         public void onCreate(Bundle savedInstanceState) {
  15.                 super.onCreate(savedInstanceState);
  16.                 setContentView(R.layout.map);
  17.                 initMapView();
  18.                 initMyLocation();
  19.         }
  20.        
  21.         @Override
  22.         protected boolean isRouteDisplayed(){
  23.                 return false;
  24.         }
  25.        
  26.         private void initMapView(){
  27.                 mapp=(MapView)findViewById(R.id.maps);
  28.                 controller=mapp.getController();
  29.                 mapp.setSatellite(true);
  30.                 mapp.setBuiltInZoomControls(true);
  31.         }
  32.        
  33.         private void initMyLocation(){
  34.                 final MyLocationOverlay overlay =new MyLocationOverlay(this, mapp);
  35.                 overlay.enableMyLocation();
  36.                 //overlay.enableCompass(); does not work in emulator
  37.                 overlay.runOnFirstFix(new Runnable(){
  38.                         public void run(){
  39.                                 controller.setZoom(8);
  40.                                 controller.animateTo(overlay.getMyLocation());
  41.                         }
  42.                 });
  43.                 mapp.getOverlays().add(overlay);
  44.                        
  45.                 }
  46.                
  47.                
  48. }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4

android manifest code
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <manifest
  4.         xmlns:android="http://schemas.android.com/apk/res/android"
  5.    package="geomanager.android.map"
  6.    android:versionCode="1"
  7.    android:versionName="1.0">
  8.         <uses-permission
  9.         android:name="android.permission.ACCESS_COARSE_LOCATION" />
  10.    
  11.     <uses-permission
  12.         android:name="android.permission.ACCESS_FINE_LOCATION" />
  13.    
  14.     <uses-permission
  15.         android:name="androis.parmission.INTERNET" />
  16.    
  17.         <application
  18.                 android:icon="@drawable/icon"
  19.                 android:label="@string/app_name">
  20.        
  21.                 <activity
  22.                 android:name=".geomanager"
  23.                 android:label="@string/app_name">
  24.                
  25.                 <intent-filter>
  26.                 <action android:name="android.intent.action.MAIN" />
  27.                 <category android:name="android.intent.category.LAUNCHER" />
  28.             </intent-filter>
  29.            
  30.         </activity>
  31.        
  32.         <uses-library android:name="com.google.android.maps" />
  33.        
  34.         <activity
  35.                 android:name=".About"
  36.                 android:label="@string/about_title"
  37.                 android:theme="@android:style/Theme.Dialog">
  38.         </activity>
  39.        
  40.         <activity
  41.                 android:name=".startjourney"
  42.                 android:label="@string/startjourney_title"
  43.                 android:theme="@android:style/Theme.Dialog">
  44.         </activity>
  45.        
  46.         <activity
  47.                 android:name=".location"
  48.                 android:label="@string/location_title" >
  49.         </activity>
  50.  
  51.      </application>
  52.      
  53.      <uses-sdk android:minSdkVersion="3" />
  54.  
  55. </manifest>
Parsed in 0.005 seconds, using GeSHi 1.0.8.4
manish raj
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Feb 10, 2011 9:51 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 3 guests