我有一个扩展的覆盖类:
短代码:
public class MapOverlay extends Overlay {
private Context context;
private ProgressDialog dDialog;
Drawable drawable;
GeoPoint MainPoint;
MapView mapView;
public MapOverlay(Context context, MapView mapView)
{
this.context = context;
this.mapView = mapView;
}
@Override
public boolean onTap(GeoPoint p, MapView mapView)
{
this.MainPoint = p;
AlertDialog.Builder dialog = new AlertDialog.Builder(context);
dialog.setMessage("Do you want to set point here?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
setPoint();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
dialog.show();
return true;
}
public void setPoint()
{
OverlayItem overlayitem = new OverlayItem(MainPoint, "Hi!", "You touched this location!");
}
我想在此活动中的地图视图上绘制触摸点:
public class MyMapLocationActivity extends MapActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
drawable = this.getResources().getDrawable(R.drawable.androidmarker);
MapOverlay myOverlay = new MapOverlay(this, mapView);
mapView.getOverlays().add(myOverlay);
mapView.postInvalidate();
}
在确认 MapOverlay 类的对话框后,我想标记触摸点。我想我错过了传递一些东西 - 我还应该做什么?