public class Text2Activity extends MapActivity {
LocationListener mLocationListener = null;
static View mPopView = null; // ���ʱ����������View
static MapView mMapView = null; protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
        setContentView(R.layout.mapviewdemo);
        
MapApp app = (MapApp)this.getApplication();
if (app.mBMapMan == null) {
app.mBMapMan = new BMapManager(getApplication());
app.mBMapMan.init(app.mStrKey, new MapApp.MyGeneralListener());
}
app.mBMapMan.start();
        // ���ʹ�õ�ͼSDK�����ʼ����ͼActivity
        super.initMapActivity(app.mBMapMan);
        
        mMapView = (MapView)findViewById(R.id.bmapView);
        mMapView.setBuiltInZoomControls(true);
        //���������Ŷ��������Ҳ��ʾoverlay,Ĭ��Ϊ������
        mMapView.setDrawOverlayWhenZooming(true);
        mLocationListener = new LocationListener() { @Override
public void onLocationChanged(Location location) { if (location != null) {
GeoPoint pt = new GeoPoint((int) (location.getLatitude() * 1e6), (int) (location.getLongitude() * 1e6));
mMapView.getController().animateTo(pt);
}
}
};
       
  
        // ���ItemizedOverlay
Drawable er = getResources().getDrawable(R.drawable.icona);  //�õ���Ҫ���ڵ�ͼ�ϵ���Դ
er.setBounds(0, 0, er.getIntrinsicWidth(), er
.getIntrinsicHeight());   //Ϊmaker����λ�úͱ߽�

mMapView.getOverlays().add(new OverItemT(er, this)); //���ItemizedOverlayʵ��mMapView

// �������ʱ�ĵ�������
mPopView=super.getLayoutInflater().inflate(R.layout.popview, null);
mMapView.addView( mPopView,
                new MapView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
                 null, MapView.LayoutParams.TOP_LEFT));
mPopView.setVisibility(View.GONE);
} @Override
protected void onPause() {
MapApp app = (MapApp)this.getApplication();
app.mBMapMan.getLocationManager().removeUpdates(mLocationListener);
app.mBMapMan.stop();
super.onPause();
}
@Override
protected void onResume() {
MapApp app = (MapApp)this.getApplication();
app.mBMapMan.getLocationManager().requestLocationUpdates(mLocationListener);
app.mBMapMan.start();
super.onResume();
} @Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
class OverItemT extends ItemizedOverlay<OverlayItem> { private List<OverlayItem> mGeoList = new ArrayList<OverlayItem>();
private Drawable er;
private Context mContext; private double mLat1 = 123.45241; // point1γ��
private double mLon1 = 41.759306; // point1���� private double mLat2 = 123.495102;
private double mLon2 = 41.763577; private double mLat3 = 123.444577;
private double mLon3 = 41.753616;
public OverItemT(Drawable er, Context context) {
super(boundCenterBottom(er)); this.er = er;
this.mContext = context; // �ø�ľ�γ�ȹ���GeoPoint����λ��΢�� (�� * 1E6)
GeoPoint p1 = new GeoPoint((int) (mLat1 * 1E6), (int) (mLon1 * 1E6));
GeoPoint p2 = new GeoPoint((int) (mLat2 * 1E6), (int) (mLon2 * 1E6));
GeoPoint p3 = new GeoPoint((int) (mLat3 * 1E6), (int) (mLon3 * 1E6)); // ����OverlayItem�������������Ϊ��item��λ�ã������ı�������Ƭ��
mGeoList.add(new OverlayItem(p1, "P1", "point1"));
mGeoList.add(new OverlayItem(p2, "P2", "point2"));
mGeoList.add(new OverlayItem(p3, "P3", "point3"));
populate();  //createItem(int)��������item��һ��������ݣ��ڵ�������ǰ�����ȵ����������
} @Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
Projection projection = mapView.getProjection(); 
for (int index = size() - 1; index >= 0; index--) { 
OverlayItem overLayItem = getItem(index);  String title = overLayItem.getTitle(); Point point = projection.toPixels(overLayItem.getPoint(), null); 
Paint paintText = new Paint();
paintText.setColor(Color.BLUE);
paintText.setTextSize(15);
System.out.println("###");
canvas.drawText(title, point.x-50, point.y+20, paintText); 
} super.draw(canvas, mapView, shadow); boundCenterBottom(er);
} @Override
protected OverlayItem createItem(int i) {
// TODO Auto-generated method stub
return mGeoList.get(i);
} @Override
public int size() {
// TODO Auto-generated method stub
return mGeoList.size();
}
@Override protected boolean onTap(int i) {
setFocus(mGeoList.get(i));

GeoPoint pt = mGeoList.get(i).getPoint();
Text2Activity.mMapView.updateViewLayout( Text2Activity.mPopView,
                new MapView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
                 pt, MapView.LayoutParams.BOTTOM_CENTER));
Text2Activity.mPopView.setVisibility(View.VISIBLE);
Toast.makeText(this.mContext, mGeoList.get(i).getSnippet(),
Toast.LENGTH_SHORT).show();
return true;
}

@Override
public boolean onTap(GeoPoint arg0, MapView arg1) {
// TODO Auto-generated method stub
Text2Activity.mPopView.setVisibility(View.GONE);
return super.onTap(arg0, arg1);
}
}