@Override
  public boolean onTap(final GeoPoint point, final MapView view) {
    if (mPopUpView != null) {
      view.removeView(mPopUpView);
    }
    // Projection接口用于屏幕像素点坐标系统和地球表面经纬度点坐标系统之间的变换
    mPopUpView = mInflater.inflate(R.layout.popup_mappoint, null);
    TextView textView = (TextView) mPopUpView.findViewById(R.id.PointName);
    if (mbStartFlag) {
      textView.setText("点击选择该点为起点");
    } else {
      textView.setText("点击选择该点为终点");
    }
    MapView.LayoutParams lp;
    lp =
        new MapView.LayoutParams(
            MapView.LayoutParams.WRAP_CONTENT,
            MapView.LayoutParams.WRAP_CONTENT,
            point,
            0,
            0,
            MapView.LayoutParams.BOTTOM_CENTER);
    view.addView(mPopUpView, lp);

    mPopUpView.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            Message msg = new Message();
            msg.what = Constants.FUNC_MAPPOINT;
            msg.obj = point;
            mContext.mHandler.sendMessage(msg);
            view.removeView(mPopUpView);
            mContext.mMapView.getOverlays().remove(this);
          }
        });

    return super.onTap(point, view);
  }
Esempio n. 2
0
  @Override
  protected boolean onTap(int index) {
    TrackInfo info = mTrackList.get(index);
    mMapController.setCenter(info.getGeoPoint());
    mMapView.removeView(mPopView);
    mMapView.addView(
        mPopView,
        new MapView.LayoutParams(
            LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT,
            info.getGeoPoint(),
            0,
            -mHeight,
            MapView.LayoutParams.BOTTOM_CENTER));

    TextView time = (TextView) mPopView.findViewById(R.id.track_time);
    TextView address = (TextView) mPopView.findViewById(R.id.track_address);

    time.setText(info.getTime().toString());
    address.setText(info.getAddress());
    return true;
  }
Esempio n. 3
0
  public LocationOverlay(
      Drawable drawable, List<TrackInfo> list, Context context, MapView mapView) {
    super(boundCenterBottom(drawable));
    this.mTrackList = list;
    this.mContext = context;
    this.mMapView = mapView;
    this.mDrawable = drawable;
    mMapController = mapView.getController();
    mHeight = drawable.getIntrinsicHeight();
    mPopView = LayoutInflater.from(mContext).inflate(R.layout.ui_track_pop_layout, null);

    for (int i = 0; i < mTrackList.size(); i++) {
      mMapOverlays.add(new OverlayItem(mTrackList.get(i).getGeoPoint(), "", "point1"));
    }

    populate();
  }
 @Override
 public void draw(Canvas canvas, MapView mapView, boolean shadow) {
   // Projection 接口用于屏幕像素点坐标系统和地球表面经纬度点坐标系统之间的变换
   Projection projection = mapView.getProjection();
   for (int index = size() - 1; index >= 0; index--) { // 遍历GeoList
     OverlayItem overLayItem = getItem(index); // 得到给定索引的item
     String title = overLayItem.getTitle();
     // 把经纬度变换到相对于MapView 左上角的屏幕像素坐标
     Point point = projection.toPixels(overLayItem.getPoint(), null);
     // 可在此处添加您的绘制代码
     Paint paintText = new Paint();
     paintText.setColor(Color.BLACK);
     paintText.setTextSize(15);
     canvas.drawText(title, point.x - 30, point.y - 25, paintText); // 绘制文本
   }
   super.draw(canvas, mapView, shadow);
   // 调整一个drawable 边界,使得(0,0)是这个drawable 底部最后一行中心的一个像素
   boundCenterBottom(marker);
 }