2

I am trying to incorporate a map into an app I am developing, so I am learning how to use them with the ItemizedOverlay functionality. I went through the tutorial on dev-android, and everything went fine except this one line.

public class HelloMapViewActivity extends MapActivity {
    @Override
    protected boolean isRouteDisplayed() 
    {
        return true;
    }

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        MapView mapView = (MapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);

        List<Overlay> mapOverlays = mapView.getOverlays();
        Drawable drawable = this.getResources().getDrawable(R.drawable.androidmarker);
        HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable); //this is the error

        GeoPoint point = new GeoPoint(19240000,-99120000);
        OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!");

        itemizedoverlay.addOverlay(overlayitem);
        mapOverlays.add(itemizedoverlay);
    }

}

The problem says:

The constructor HelloItemizedOverlay(drawable) is undefined, 

would anyone be able to tell me what im doing wrong? As well when I follow what Eclipse tells me to do and put null next to it in the parameters, it clears the problem but does not show up with the drawable over the map.

Paul Hiemstra
  • 59,984
  • 12
  • 142
  • 149
Nicholas Pesa
  • 2,156
  • 2
  • 24
  • 45
  • Another tutorial I used when I was starting off, for reference: http://codemagician.wordpress.com/2010/05/06/android-google-mapview-tutorial-done-right/ – WilHall Jan 30 '12 at 01:42
  • thank you that helped clear up the error, but still no drawable showing up overlaying the map – Nicholas Pesa Jan 30 '12 at 02:01

3 Answers3

0

Here is an example how my HelloItemizedOverlay was when I was working with Google Maps :

import java.util.ArrayList;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

@SuppressWarnings("rawtypes")
public class HelloItemizedOverlay extends ItemizedOverlay {
    private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
    Context mContext;

    public HelloItemizedOverlay(Drawable defaultMarker) {
        super(boundCenterBottom(defaultMarker));
    }

    public HelloItemizedOverlay(Drawable defaultMarker, Context context) {
        super(boundCenterBottom(defaultMarker));
        mContext = context;
    }

    @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();
    }

    @Override
    protected boolean onTap(int index) {
        OverlayItem item = mOverlays.get(index);
        AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
        dialog.setTitle(item.getTitle());
        dialog.setMessage(item.getSnippet());
        dialog.show();
        return true;
    }
}
david
  • 3,225
  • 9
  • 30
  • 43
hardartcore
  • 16,886
  • 12
  • 75
  • 101
0

I think this is a good basic source to learn http://developer.android.com/resources/tutorials/views/hello-mapview.html

April Smith
  • 1,810
  • 2
  • 28
  • 52
  • as i explained in the beginning of my question, all of this code is from that tutorial, i seem to have everything in the right place for it, its just not bringing up my items over the map – Nicholas Pesa Jan 30 '12 at 18:03
-1

HelloitemizedOverlay konstructor also needs the context.

shippy
  • 1
  • 1
    please, try to avoid posting additions to other answers as a separate answer. You can use either comment or you need to organize your post as a separate answer – Pavel Dudka Feb 04 '13 at 22:55