List <overlay>方法</overlay>的问题

时间:2012-04-10 16:12:43

标签: android

我正在制作一个包含Google API for Geo Localization的应用程序。我在其中创建了一个Itemized Overlay和一个位置图的地图,我无法通过手动设置pint-points在模拟器上看到地图。我创建了一个List,哪个方法“add”不能用于我告诉你的这个类,这个类包含很多错误。

import java.util.ArrayList;
import android.content.Context;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;

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

public class CheckInMapItemizedOverlay extends com.readystatesoftware.mapviewballoons.BalloonItemizedOverlay<OverlayItem>  { 

Drawable drawable;
boolean chkScreen;
String gmap_id;

private ArrayList<OverlayItem> m_overlays = new ArrayList<OverlayItem>();
private Context context;

public CheckInMapItemizedOverlay(Drawable defaultMarker, MapView mapView,boolean chkscr,String gmapid) {

    super(boundCenter(defaultMarker), mapView);

    drawable = defaultMarker;
//      int w = drawable.getIntrinsicWidth();
//      int h = drawable.getIntrinsicHeight();
//      drawable.setBounds(-w / 2, -h, w / 2, 0);

    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());


    context = mapView.getContext();
    chkScreen = chkscr;
    gmap_id = gmapid;
}

//  public static Drawable boundMyDrawable(Drawable d)
//  {
//       d.setBounds(d.getIntrinsicWidth() /- 2, d.getIntrinsicHeight() / -2,
//                   d.getIntrinsicWidth() / 2, d.getIntrinsicHeight() / 2);
//       return d;
//  }


public void addOverlay(OverlayItem overlay) {
    m_overlays.add(overlay);
    populate();

}

// all below override methods
protected OverlayItem createItem(int i) {
    return m_overlays.get(i);
}


public int size() {
    return m_overlays.size();
}



protected boolean onBalloonTap(int index, OverlayItem item) {
//      Toast.makeText(c, "onBalloonTap for overlay index " + index,
//              Toast.LENGTH_LONG).show();

    if(chkScreen == true)
    {
        Intent intent = new Intent(context,CheckInDetailsArrow.class);

        intent.putExtra("GMAP_ID",gmap_id);
        //System.out.println("Lat: "+item.getPoint().getLatitudeE6() /1E6);
        //System.out.println("lng: "+item.getPoint().getLongitudeE6() /1E6);

        intent.putExtra("Lat", item.getPoint().getLatitudeE6() / 1E6);
        intent.putExtra("Lng", item.getPoint().getLongitudeE6() /1E6);
        intent.putExtra("Name", item.getTitle());
        intent.putExtra("Addr", item.getSnippet());


        //System.out.println("Getting marker: "+);

                //HotSpotSettings.setBitmap(((BitmapDrawable)drawable).getBitmap(),context);
        context.startActivity(intent);

        return true;    
    }
    else
    {
        return false;
    }

}

@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow)
{
    if(!shadow)
    {
        super.draw(canvas, mapView, false);
        boundCenter(drawable);
    }
  }

}

0 个答案:

没有答案