It isn't a NullPointerException??

public void onCreate(Bundle savedInstanceState) {

                GeoPoint point = new GeoPoint(19240000,-99120000);
                OverlayItem overlayitem = new OverlayItem(point, "",
"");

                itemizedOverlay.addOverlay(overlayitem);  //NULL
REFERENCE HERE
                 ...
}

You are trying to call a method in a null reference. This may solve
the problem:

public void onCreate(Bundle savedInstanceState) {

                GeoPoint point = new GeoPoint(19240000,-99120000);
                OverlayItem overlayitem = new OverlayItem(point, "",
"");
                drawable = this.getResources().getDrawable
                    (R.drawable.androidmarker);
                itemizedOverlay = new ItemizedOverlay(drawable);
                itemizedOverlay.addOverlay(overlayitem);  //NULL
REFERENCE HERE
                 ...
}


=D

On 2 set, 04:01, sweet <[email protected]> wrote:
> I've a problem with ItemizedOverlay in a mapView.
> I had folow the tuto HelloMapView in the android developpers website
> and i can't display the itemized overlay in the bottom of the tuto.
> I show you my code:
>
> mapview java:
>
> import java.util.List;
>
> import android.content.Intent;
> import android.graphics.drawable.Drawable;
> import android.os.Bundle;
> import android.view.Menu;
> import android.view.MenuInflater;
> import android.view.MenuItem;
> import android.widget.LinearLayout;
> import android.widget.ZoomControls;
>
> import com.google.android.maps.GeoPoint;
> import com.google.android.maps.MapActivity;
> import com.google.android.maps.MapView;
> import com.google.android.maps.Overlay;
> import com.google.android.maps.OverlayItem;
>
> public class Map extends MapActivity {
>         List<Overlay> mapOverlays;
>         Drawable drawable;
>         ItemizedOverlay itemizedOverlay;
>         LinearLayout linearLayout;
>         MapView mapView;
>         ZoomControls mZoom;
>
>         @Override
>     public void onCreate(Bundle savedInstanceState) {
>
>                 GeoPoint point = new GeoPoint(19240000,-99120000);
>                 OverlayItem overlayitem = new OverlayItem(point, "", "");
>                 itemizedOverlay.addOverlay(overlayitem);
>                 mapOverlays.add(itemizedOverlay);
>                 mapOverlays = mapView.getOverlays();
>                 drawable = this.getResources().getDrawable
> (R.drawable.androidmarker);
>                 itemizedOverlay = new ItemizedOverlay(drawable);
>
>                 super.onCreate(savedInstanceState);
>         setContentView(R.layout.map);
>                 linearLayout = (LinearLayout) findViewById(R.id.zoomview);
>         mapView = (MapView) findViewById(R.id.mapview);
>         mapView.setBuiltInZoomControls(true);
>         mapView.setSatellite(true);
>     }
>         protected boolean isRouteDisplayed() {
>                 return false;
>         }
>
> }
>
> ItemizedOverlay Java:
>
> import android.graphics.drawable.Drawable;
> import java.util.ArrayList;
>
> import com.google.android.maps.OverlayItem;
>
> public class ItemizedOverlay extends
> com.google.android.maps.ItemizedOverlay {
>
>         private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>
> ();
>
>         public ItemizedOverlay(Drawable defaultMarker) {
>                 super(boundCenterBottom(defaultMarker));
>
>         }
>
>         @Override
>         protected OverlayItem createItem(int i) {
>           return mOverlays.get(i);
>         }
>
>         @Override
>         public int size() {
>                 return mOverlays.size();
>         }
>         public void addOverlay(OverlayItem overlay) {
>             mOverlays.add(overlay);
>             populate();
>         }
>
> }
>
> map XML:
>
> <?xml version="1.0" encoding="utf-8"?>
> <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
>         android:id="@+id/mapview"
>         android:layout_width="fill_parent"
>         android:layout_height="fill_parent"
>         android:clickable="true"
>         android:apiKey="0GWRUwsy0_POHxdWofVfhZeFLwtgkcn7ouMfwcg"/>
>         <LinearLayout
>     android:id="@+id/zoomview"
>     android:layout_width="wrap_content"
>     android:layout_height="wrap_content"
>     android:layout_alignBottom="@id/mapview"
>     android:layout_centerHorizontal="true"/>
> </LinearLayout>
>
> If anyone see any error in this code ??? (I think the mistake is in
> the itemizedOverlay java class but i can't find it with the debug
> mode)
> Thanks
> Sweet
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to