我需要通过脉冲动画显示位置 A 和位置 B。我可以使用下面的代码来实现这一点。但我面临的问题是,当缩放级别发生变化时,GroundOverlay 也会改变其大小。如果位置A和B彼此靠近(即地图放大级别较高),则脉冲半径太大。当我缩小时,它变得太小了。
无论地图的缩放级别如何,如何保持叠加层的大小相同。
下面的代码是从这里引用的:Google Maps v2 上的动画透明圆没有正确动画化
private void showRipples(LatLng latLng, int color) {
GradientDrawable d = new GradientDrawable();
d.setShape(GradientDrawable.OVAL);
d.setSize(500, 500);
d.setColor(ContextCompat.getColor(Activity.this, color));
d.setStroke(0, Color.TRANSPARENT);
final Bitmap bitmap = Bitmap.createBitmap(d.getIntrinsicWidth()
, d.getIntrinsicHeight()
, Bitmap.Config.ARGB_8888);
// Convert the drawable to bitmap
final Canvas canvas = new Canvas(bitmap);
d.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
d.draw(canvas);
// Radius of the circle
final int radius = getResources().getDimensionPixelSize(R.dimen.ripple_radius);
// Add the circle to the map
final GroundOverlay circle = googleMap.addGroundOverlay(new GroundOverlayOptions()
.position(latLng, …Run Code Online (Sandbox Code Playgroud)