有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何删除地图标记上的阴影?

我正在谷歌地图上显示一个自定义标记。它们的位置很好,但它们有一个有趣的影子。我怎样才能消除阴影alt text

@Override
        public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
            super.draw(canvas, mapView, shadow);

            // ---translate the GeoPoint to screen pixels---
            Point screenPts = new Point();
            mapView.getProjection().toPixels(geoPnt, screenPts);

            // ---add the marker---
            /*Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.pushpin);
            canvas.drawBitmap(bmp, screenPts.x, screenPts.y - 67, null);*/
            return true;
        }
    }

共 (2) 个答案

  1. # 1 楼答案

    调用重写的方法时,我会尝试为shadow参数传递false

    这意味着它应该看起来像super.draw(canvas, mapView, false)

  2. # 2 楼答案

    试试这个:

    @Override
        public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
          if (!shadow) {
            super.draw(canvas, mapView, shadow);
    
            //  -translate the GeoPoint to screen pixels -
            Point screenPts = new Point();
            mapView.getProjection().toPixels(geoPnt, screenPts);
    
            //  -add the marker -
            Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.pushpin);
            canvas.drawBitmap(bmp, screenPts.x, screenPts.y - 67, null);
          }
          return true;
        }
    }