Need help for my map app please.

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

Need help for my map app please.

Postby PaddyWang » Sun Dec 12, 2010 12:39 am

Hi guys,

I m just trying out the map api. On the the main page when starts the app only has one button which is go. What I wanna do here is when I press go, go to the map. Just trying to use intent at the same time. But then my app crashed. I checked the debug thing. It says noPointerException.
Here is my main java file.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.map.test;
  2.  
  3. import android.app.Activity;
  4. import android.content.Intent;
  5. import android.os.Bundle;
  6. import android.view.View;
  7. import android.view.View.OnClickListener;
  8. import android.widget.Button;
  9.  
  10. public class MapTesting extends Activity implements OnClickListener
  11. {
  12.         @Override
  13.         public void onCreate(Bundle savedInstanceState)
  14.         {
  15.                         super.onCreate(savedInstanceState);
  16.                         setContentView(R.layout.main);
  17.                         Button go=(Button)findViewById(R.id.go);
  18.                         go.setOnClickListener(this);
  19.         }
  20.         public void onClick(View v)
  21.         {
  22.                 Intent go = new Intent(v.getContext(), Map.class);
  23.                 startActivity(go);
  24.         }
  25.        
  26.        
  27. }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
PaddyWang
Freshman
Freshman
 
Posts: 4
Joined: Sun Oct 31, 2010 4:54 pm

Top

Re: Need help for my map app please.

Postby PaddyWang » Sun Dec 12, 2010 12:41 am

Here is my map java file.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.map.test;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. import android.graphics.drawable.Drawable;
  7. import android.os.Bundle;
  8. import android.widget.LinearLayout;
  9.  
  10. import com.google.android.maps.GeoPoint;
  11. import com.google.android.maps.ItemizedOverlay;
  12. import com.google.android.maps.MapActivity;
  13. import com.google.android.maps.MapView;
  14. import com.google.android.maps.Overlay;
  15. import com.google.android.maps.OverlayItem;
  16.  
  17. public class Map extends MapActivity
  18. {
  19.         @Override
  20.         public void onCreate(Bundle savedInstanceState)
  21.         {
  22.                         super.onCreate(savedInstanceState);
  23.                         setContentView(R.layout.main);
  24.                         LinearLayout linearLayout = (LinearLayout)findViewById(R.id.zoomview);
  25.                         MapView mapView = (MapView) findViewById(R.id.mapview);
  26.                         mapView.setBuiltInZoomControls(true);
  27.                         List<Overlay> mapOverlays = mapView.getOverlays();
  28.                         Drawable drawable = this.getResources().getDrawable(R.drawable.androidmarker1);
  29.                         HelloItemizedOverlay itemizedOverlay = new HelloItemizedOverlay(drawable);
  30.                         GeoPoint gmcs = new GeoPoint(32776389, -117069167);
  31.                         OverlayItem overlayitem = new OverlayItem(gmcs, "GMCS","This is where the Computer Science department is located at SDSU");                    
  32.                         itemizedOverlay.addOverlay(overlayitem); mapOverlays.add(itemizedOverlay);
  33.         }
  34.         @Override
  35.         protected boolean isRouteDisplayed() { return false;}
  36.         public class HelloItemizedOverlay extends ItemizedOverlay<OverlayItem>
  37.         {
  38.                 private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();                       
  39.                 public HelloItemizedOverlay(Drawable defaultMarker)
  40.                 {       super(boundCenterBottom(defaultMarker));        }
  41.                 public void addOverlay(OverlayItem overlay)
  42.                 {       mOverlays.add(overlay); populate();     }
  43.                 protected OverlayItem createItem(int i)
  44.                 {       return mOverlays.get(i);        }
  45.                 public int size()
  46.                 {       return mOverlays.size();        }
  47.         }
  48. }
  49.  
Parsed in 0.037 seconds, using GeSHi 1.0.8.4
PaddyWang
Freshman
Freshman
 
Posts: 4
Joined: Sun Oct 31, 2010 4:54 pm

Re: Need help for my map app please.

Postby PaddyWang » Sun Dec 12, 2010 12:42 am

Last my manifest file.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3.       package="com.map.test"
  4.       android:versionCode="1"
  5.       android:versionName="1.0">
  6.     <application android:icon="@drawable/icon" android:label="@string/app_name">
  7.        <uses-library android:name="com.google.android.maps" />
  8.        <uses-permission android:name="android.permission.INTERNET" />
  9.         <activity android:name=".MapTesting"
  10.                   android:label="@string/app_name">
  11.             <intent-filter>
  12.                 <action android:name="android.intent.action.MAIN" />
  13.                 <category android:name="android.intent.category.LAUNCHER" />
  14.             </intent-filter>
  15.         </activity>
  16.                 <activity android:name="Map"
  17.                   android:label="Map">
  18.             <intent-filter>
  19.                 <action android:name="android.intent.action.VIEW" />
  20.                 <category android:name="map"></category>
  21.                 <category android:name="android.intent.category.DEFAULT" />
  22.             </intent-filter>
  23.         </activity>
  24.  
  25.     </application>
  26.  
  27.  
  28. </manifest>
  29.  
Parsed in 0.038 seconds, using GeSHi 1.0.8.4


Thanks in advance.
PaddyWang
Freshman
Freshman
 
Posts: 4
Joined: Sun Oct 31, 2010 4:54 pm

Re: Need help for my map app please.

Postby PaddyWang » Sun Dec 12, 2010 2:13 am

Never mind guys, I found the mistake. cheers.
PaddyWang
Freshman
Freshman
 
Posts: 4
Joined: Sun Oct 31, 2010 4:54 pm

Re: Need help for my map app please.

Postby a.y.360 » Wed Jan 05, 2011 9:30 pm

Hey.
Having a similar problem, how did you resolve yours?
thnx
a.y.360
Freshman
Freshman
 
Posts: 2
Joined: Wed Jan 05, 2011 7:51 pm

Re: Need help for my map app please.

Postby Daybreak » Thu Jan 06, 2011 7:29 am

You can check your LogCat to find out the problem where it is.
Daybreak
Freshman
Freshman
 
Posts: 4
Joined: Thu Dec 30, 2010 3:54 am

Top

Re: Need help for my map app please.

Postby a.y.360 » Thu Jan 06, 2011 12:42 pm

Thanks. Problem resolved.
a.y.360
Freshman
Freshman
 
Posts: 2
Joined: Wed Jan 05, 2011 7:51 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 1 guest