views:

1039

answers:

1

Got some errors following the tutorial for MapView when i was going to integrate overlays.

TravelBuddy.java

package com.jappapps.android.travelbuddy;
import java.util.List;

import android.graphics.drawable.Drawable;
import android.os.Bundle;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

public class TravelBuddy extends MapActivity {
List<Overlay> mapOverlays;
Drawable drawable;
Overlays itemizedOverlay;
/** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.main); // changed to lowercase
       MapView mapView = (MapView) findViewById(R.id.mapview); // match id in main.xml
       mapView.setBuiltInZoomControls(true);
       mapOverlays = mapView.getOverlays();
       drawable = this.getResources().getDrawable(R.drawable.androidmarker);
       itemizedOverlay = new Overlays(drawable);
   }

    @Override
    protected boolean isRouteDisplayed() {
        return false;
     }
  }

Overlays.java

 package com.jappapps.android.travelbuddy;

 import java.util.ArrayList;

 import android.graphics.drawable.Drawable;

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

 public class Overlays extends ItemizedOverlay {
public Overlays(Drawable arg0) {
    super(arg0);
    Object overlayitem;
    ItemizedOverlay.addOverlay(overlayitem);
    Object itemizedoverlay;
    ArrayList<OverlayItem> mapOverlays;
    mapoverlays.add(itemizedOverlay);
}
private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
super(boundCenterBottom(defaultMarker));
public void addOverlay(OverlayItem overlay) {
    mOverlays.add(overlay);
    populate();}
    @Override
    protected OverlayItem createItem(int i) {
      return mOverlays.get(i);

    }
    @Override
    public int size() {
        return 0;
    }
  }

Sorry if i look like a complete newbie, but i am trying to learn and i got an awesome app idea which needs mapview, webview, overlays and tabs.

A: 

I don't know if this'll help or not, but I've put a working example of mapping and overlays under "Using the Google Maps API to map a location and add a marker to the map." at "http://www.androidref.com/". Take a look, and if it's related to your question, maybe you can spot the problem.

AndroidRef.com