0

我试图在地图中心显示一个点,每次移动地图时它都应该在中心。我在地图中添加了一个点,但是当我移动地图时它不再位于中心?

4

1 回答 1

2
Paint mPaint = new Paint();
    mPaint.setDither(true);
    mPaint.setColor(Color.RED);
    mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeWidth(2);

    Point p1 = new Point();
    Point p2 = new Point();

        Path path = new Path();
        Projection projection = mapv.getProjection();
        for(int i=0; i<listOfPoints.size()-2; i++)
        {
//              System.out.println(listOfPoints.get(i).getLatitudeE6()+"  "+ listOfPoints.get(i).getLatitudeE6());
            projection.toPixels(listOfPoints.get(i), p1);
            projection.toPixels(listOfPoints.get(i+1), p2);

            path.moveTo(p2.x, p2.y);
            path.lineTo(p1.x,p1.y);  
        }
        canvas.drawPath(path, mPaint);
于 2012-05-03T11:53:23.083 回答